You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Comrad/script/install

240 lines
4.5 KiB
Plaintext

4 years ago
#!/bin/bash
4 years ago
# funcs (mac doesnt have realpath)
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
4 years ago
# install pyenv?
4 years ago
4 years ago
echo "
4 years ago
# # ## # # ### ## ### ####
# # # # #### # # # # # # #
## # # #### ### # # # # ###
# # # # # # # # #### # # #
# # ## # # # # # # ### ####
4 years ago
4 years ago
installing...
4 years ago
4 years ago
"
4 years ago
echo '
1) setting up folder...
4 years ago
'
# install dir?
4 years ago
echo "Where should komrade live on your device?"
path_komrade_default="`realpath ~/komrade`"
read -p "[$path_komrade_default] " path_komrade
4 years ago
if [ -z "$path_komrade" ]
then
4 years ago
path_komrade=$path_komrade_default
4 years ago
fi
4 years ago
4 years ago
if [ ! -d "$path_komrade" ]
then
mkdir -p $path_komrade
echo "created $path_komrade"
fi
path_lib="$path_komrade/lib"
if [ ! -d "$path_lib" ]
then
mkdir -p $path_lib
echo "created $path_lib"
fi
4 years ago
4 years ago
echo '
4 years ago
2) downloading Komrade...
4 years ago
'
path_repo="$path_komrade/code"
4 years ago
if command -v git &> /dev/null
4 years ago
then
4 years ago
echo "using git..."
4 years ago
if [ -d "$path_repo" ]
4 years ago
then
cd $path_repo
git pull
else
cd $path_komrade
4 years ago
echo "Use HTTPS or SSH for git?"
read -p "[HTPS/ssh] " git_method
4 years ago
if [ "$git_method" = "ssh" ]
4 years ago
then
echo "using ssh..."
git clone git@github.com:Komrade/Komrade.git
4 years ago
git checkout installer
4 years ago
else
git clone https://github.com/Komrade/Komrade.git
4 years ago
git checkout installer
4 years ago
fi
4 years ago
mv Komrade code
fi
else
cd $path_komrade
4 years ago
curl -s -LO https://github.com/Komrade/Komrade/archive/installer.zip
unzip installer.zip
rm installer.zip
cp -rT Komrade-installer code
rm -r Komrade-installer
4 years ago
fi
4 years ago
4 years ago
#########################################################
echo '
3) building Themis, cryptography backend...
'
cd "$path_lib"
# pwd
git clone https://github.com/cossacklabs/themis.git
cd themis
make
sudo make install
##########################################################
4 years ago
4 years ago
echo '
4) setting up python...
4 years ago
4 years ago
# '
4 years ago
4 years ago
cd $path_komrade
4 years ago
path_conda="$path_komrade/lib/miniconda3"
4 years ago
# ### Detect if python 3.7?
# pyv="$(python3 -c 'import sys; print(sys.version_info[0:2])')"
# if [ ! "$pyv" = "(3, 7)" ]
# then
4 years ago
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
#echo ${machine}
if [ "$machine" = "Linux" ]
then
4 years ago
if [ ! -f "miniconda.sh" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Linux-x86_64.sh -o miniconda.sh
chmod +x miniconda.sh
fi
4 years ago
./miniconda.sh -b -f -p "$path_conda"
4 years ago
#rm miniconda.sh
4 years ago
fi
if [ "$machine" = "Mac" ]
4 years ago
then
4 years ago
if [ ! -f "miniconda.sh" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-MacOSX-x86_64.sh -o miniconda.sh
chmod +x miniconda.sh
fi
4 years ago
./miniconda.sh -b -f -p "$path_conda"
4 years ago
# rm miniconda.sh
4 years ago
fi
if [ "$machine" = "Cygwin" ]
4 years ago
then
arch="$(uname -m)"
if [ "$arch" = "x86_64" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Windows-x86_64.exe -o miniconda.exe
else
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Windows-x86.exe -o miniconda.exe
fi
4 years ago
./miniconda.exe -b -f -p "$path_conda"
4 years ago
# rm miniconda.exe
4 years ago
fi
4 years ago
4 years ago
4 years ago
4 years ago
# activate conda
4 years ago
export PATH="$path_conda/bin:$PATH"
4 years ago
source "$path_conda/etc/profile.d/conda.sh"
4 years ago
condaexec="conda"
pythonexec="python"
4 years ago
echo '
5) creating virtual environment...
4 years ago
'
4 years ago
path_venv="$path_repo/venv"
4 years ago
# cd $path_komrade
cd $path_repo
echo "Now using python 1: `which python`"
4 years ago
$condaexec create -y -p "$path_venv" python=3.7 cartopy pip virtualenv
4 years ago
#$condaexec activate "$path_venv"
4 years ago
echo "Now using python 2: `which python`"
# $pythonexec -m pip install virtualenv
4 years ago
# $pythonexec -m virtualenv venv
# . venv/bin/activate
4 years ago
echo "Now using python 3: `which python`"
4 years ago
4 years ago
python -m pip install -r requirements.txt
4 years ago
4 years ago
echo '
4 years ago
6) adding komrade bin folder to path
4 years ago
4 years ago
'
4 years ago
4 years ago
echo "
4 years ago
4 years ago
# komrade
export PATH=\"$path_repo/bin:\$PATH\"
4 years ago
4 years ago
" >> ~/.bashrc
4 years ago
4 years ago
export PATH="$path_repo/bin:$PATH"
4 years ago
4 years ago
echo "Now run Komrade with:
4 years ago
4 years ago
komrade-app [GUI interface -- alpha]
4 years ago
If that doesn't work, try running this series of comands:
source $path_conda/etc/profile.d/conda.sh
export PATH=\"$path_conda/bin:\$PATH\"
conda activate $path_venv
python -m pip install -r $path_repo/requirements.txt
python $path_repo/komrade/app/main.py
4 years ago
"