2020-09-14 15:59:11 +00:00
|
|
|
#!/bin/bash
|
2020-09-14 13:38:27 +00:00
|
|
|
|
2020-09-26 13:22:08 +00:00
|
|
|
# funcs (mac doesnt have realpath)
|
|
|
|
realpath() {
|
|
|
|
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
|
|
|
|
}
|
2020-09-28 12:59:24 +00:00
|
|
|
|
|
|
|
echo "$1 $2 $3"
|
2020-09-26 13:24:53 +00:00
|
|
|
|
2020-09-26 13:22:08 +00:00
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
# install pyenv?
|
2020-09-14 14:40:40 +00:00
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
echo "
|
2020-09-14 13:38:27 +00:00
|
|
|
# # ## # # ### ## ### ####
|
|
|
|
# # # # #### # # # # # # #
|
|
|
|
## # # #### ### # # # # ###
|
|
|
|
# # # # # # # # #### # # #
|
|
|
|
# # ## # # # # # # ### ####
|
2020-09-14 15:59:11 +00:00
|
|
|
|
2020-09-14 13:38:27 +00:00
|
|
|
|
|
|
|
installing...
|
2020-09-14 16:01:38 +00:00
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
"
|
2020-09-14 16:01:38 +00:00
|
|
|
|
|
|
|
echo '
|
|
|
|
1) setting up folder...
|
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
'
|
|
|
|
# install dir?
|
2020-09-14 17:01:36 +00:00
|
|
|
echo "Where should komrade live on your device?"
|
|
|
|
path_komrade_default="`realpath ~/komrade`"
|
2020-09-28 12:42:29 +00:00
|
|
|
|
2020-09-28 12:59:24 +00:00
|
|
|
if [ "$1" = "-n" ]
|
2020-09-28 12:42:29 +00:00
|
|
|
then
|
|
|
|
read -p "[$path_komrade_default] " path_komrade
|
|
|
|
else
|
|
|
|
path_komrade=$path_komrade_default
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
if [ -z "$path_komrade" ]
|
|
|
|
then
|
2020-09-14 17:02:11 +00:00
|
|
|
path_komrade=$path_komrade_default
|
2020-09-14 15:59:11 +00:00
|
|
|
fi
|
2020-09-22 13:36:20 +00:00
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
if [ ! -d "$path_komrade" ]
|
|
|
|
then
|
|
|
|
mkdir -p $path_komrade
|
|
|
|
echo "created $path_komrade"
|
|
|
|
fi
|
|
|
|
|
2020-09-26 08:09:01 +00:00
|
|
|
path_lib="$path_komrade/lib"
|
|
|
|
if [ ! -d "$path_lib" ]
|
|
|
|
then
|
|
|
|
mkdir -p $path_lib
|
|
|
|
echo "created $path_lib"
|
|
|
|
fi
|
2020-09-28 13:22:47 +00:00
|
|
|
|
2020-09-28 13:17:52 +00:00
|
|
|
path_bin="$path_komrade/code/bin"
|
2020-09-28 13:20:49 +00:00
|
|
|
# if [ ! -d "$path_bin" ]
|
|
|
|
# then
|
|
|
|
# mkdir -p $path_bin
|
|
|
|
# echo "created $path_bin"
|
|
|
|
# fi
|
2020-09-27 12:08:32 +00:00
|
|
|
|
2020-09-14 16:42:03 +00:00
|
|
|
|
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
echo '
|
2020-09-14 16:01:38 +00:00
|
|
|
|
|
|
|
2) downloading Komrade...
|
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
path_repo="$path_komrade/code"
|
2020-09-14 16:56:54 +00:00
|
|
|
if command -v git &> /dev/null
|
2020-09-14 15:59:11 +00:00
|
|
|
then
|
2020-09-14 17:01:36 +00:00
|
|
|
echo "using git..."
|
2020-09-14 16:52:59 +00:00
|
|
|
if [ -d "$path_repo" ]
|
2020-09-14 15:59:11 +00:00
|
|
|
then
|
|
|
|
cd $path_repo
|
|
|
|
git pull
|
|
|
|
else
|
|
|
|
cd $path_komrade
|
2020-09-14 18:49:14 +00:00
|
|
|
|
2020-09-28 12:59:24 +00:00
|
|
|
if [ "$1" = "-n" ]
|
2020-09-28 12:42:29 +00:00
|
|
|
then
|
|
|
|
echo "Use HTTPS or SSH for git?"
|
|
|
|
read -p "[HTTPS/ssh] " git_method
|
|
|
|
else
|
|
|
|
git_method="https"
|
|
|
|
fi
|
|
|
|
|
2020-09-17 05:01:59 +00:00
|
|
|
if [ "$git_method" = "ssh" ]
|
2020-09-14 18:49:14 +00:00
|
|
|
then
|
|
|
|
echo "using ssh..."
|
|
|
|
git clone git@github.com:Komrade/Komrade.git
|
2020-09-22 13:38:52 +00:00
|
|
|
git checkout installer
|
2020-09-14 18:49:14 +00:00
|
|
|
else
|
|
|
|
git clone https://github.com/Komrade/Komrade.git
|
2020-09-22 13:38:52 +00:00
|
|
|
git checkout installer
|
2020-09-14 18:49:14 +00:00
|
|
|
fi
|
2020-09-14 15:59:11 +00:00
|
|
|
mv Komrade code
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
cd $path_komrade
|
2020-09-22 13:38:52 +00:00
|
|
|
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
|
2020-09-14 15:59:11 +00:00
|
|
|
fi
|
2020-09-22 13:27:34 +00:00
|
|
|
|
2020-09-22 12:54:50 +00:00
|
|
|
|
2020-09-26 08:09:01 +00:00
|
|
|
#########################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########################################################
|
|
|
|
|
2020-09-14 16:42:03 +00:00
|
|
|
|
|
|
|
|
2020-09-14 16:01:38 +00:00
|
|
|
echo '
|
|
|
|
|
2020-09-26 08:09:01 +00:00
|
|
|
4) setting up python...
|
2020-09-14 16:01:38 +00:00
|
|
|
|
2020-09-22 11:13:48 +00:00
|
|
|
# '
|
|
|
|
|
2020-09-14 15:59:11 +00:00
|
|
|
|
2020-09-14 16:42:03 +00:00
|
|
|
|
|
|
|
|
2020-09-22 13:26:18 +00:00
|
|
|
cd $path_komrade
|
|
|
|
|
2020-09-25 11:44:39 +00:00
|
|
|
path_conda="$path_komrade/lib/miniconda3"
|
2020-09-22 13:27:34 +00:00
|
|
|
# ### Detect if python 3.7?
|
|
|
|
# pyv="$(python3 -c 'import sys; print(sys.version_info[0:2])')"
|
|
|
|
# if [ ! "$pyv" = "(3, 7)" ]
|
2020-09-22 13:26:18 +00:00
|
|
|
# then
|
2020-09-22 13:27:34 +00:00
|
|
|
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
|
2020-09-25 11:50:43 +00:00
|
|
|
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
|
2020-09-25 11:44:39 +00:00
|
|
|
./miniconda.sh -b -f -p "$path_conda"
|
2020-09-25 11:50:43 +00:00
|
|
|
#rm miniconda.sh
|
2020-09-27 12:08:32 +00:00
|
|
|
|
|
|
|
### install themis from source
|
|
|
|
|
|
|
|
if [ ! -f "/usr/local/lib/libthemis.so" ]
|
|
|
|
then
|
|
|
|
if [ ! -f "/usr/lib/libthemis.so" ]
|
|
|
|
then
|
|
|
|
echo '
|
|
|
|
|
|
|
|
3) building Themis, cryptography backend...
|
|
|
|
|
|
|
|
'
|
|
|
|
cd "$path_lib"
|
|
|
|
# pwd
|
|
|
|
git clone https://github.com/cossacklabs/themis.git
|
|
|
|
cd themis
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
### install zbar library
|
|
|
|
sudo apt install zbar-tools
|
|
|
|
|
2020-09-22 13:36:20 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$machine" = "Mac" ]
|
2020-09-22 13:27:34 +00:00
|
|
|
then
|
2020-09-25 11:50:43 +00:00
|
|
|
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
|
2020-09-25 11:44:39 +00:00
|
|
|
./miniconda.sh -b -f -p "$path_conda"
|
2020-09-25 11:50:43 +00:00
|
|
|
# rm miniconda.sh
|
2020-09-27 12:08:32 +00:00
|
|
|
|
2020-09-28 12:56:29 +00:00
|
|
|
if command -v /usr/local/bin/brew &> /dev/null
|
|
|
|
then
|
|
|
|
cd "$path_lib"
|
|
|
|
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
|
|
|
|
fi
|
2020-09-27 12:08:32 +00:00
|
|
|
|
|
|
|
# brew install
|
2020-09-28 12:56:29 +00:00
|
|
|
/usr/local/bin/brew tap cossacklabs/tap
|
|
|
|
/usr/local/bin/brew install libthemis
|
2020-09-27 12:08:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
# install zbar library
|
2020-09-28 12:56:29 +00:00
|
|
|
/usr/local/bin/brew install zbar
|
2020-09-27 12:08:32 +00:00
|
|
|
|
|
|
|
|
2020-09-22 13:36:20 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$machine" = "Cygwin" ]
|
2020-09-22 13:27:34 +00:00
|
|
|
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
|
2020-09-22 13:26:18 +00:00
|
|
|
|
2020-09-25 11:44:39 +00:00
|
|
|
./miniconda.exe -b -f -p "$path_conda"
|
2020-09-25 11:50:43 +00:00
|
|
|
# rm miniconda.exe
|
2020-09-27 12:08:32 +00:00
|
|
|
|
|
|
|
### install themis from source
|
|
|
|
if [ ! -f "/usr/local/lib/libthemis.so" ]
|
|
|
|
then
|
|
|
|
if [ ! -f "/usr/lib/libthemis.so" ]
|
|
|
|
then
|
|
|
|
echo '
|
|
|
|
|
|
|
|
3) building Themis, cryptography backend...
|
|
|
|
|
|
|
|
'
|
|
|
|
cd "$path_lib"
|
|
|
|
# pwd
|
|
|
|
git clone https://github.com/cossacklabs/themis.git
|
|
|
|
cd themis
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
### install zbar using apt-cyg
|
|
|
|
# installing apt-cyg
|
|
|
|
if ! command -v apt-cyg &> /dev/null
|
|
|
|
then
|
|
|
|
echo "installing apt-cyg"
|
|
|
|
lynx -source https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
|
|
|
|
install apt-cyg /bin
|
|
|
|
fi
|
|
|
|
# installing zbar
|
|
|
|
apt-cyg install zbar
|
2020-09-22 13:27:34 +00:00
|
|
|
fi
|
2020-09-22 13:36:20 +00:00
|
|
|
|
2020-09-25 11:44:39 +00:00
|
|
|
|
2020-09-25 13:17:03 +00:00
|
|
|
|
2020-09-25 11:44:39 +00:00
|
|
|
# activate conda
|
2020-09-25 11:50:43 +00:00
|
|
|
export PATH="$path_conda/bin:$PATH"
|
2020-09-25 13:17:03 +00:00
|
|
|
|
|
|
|
source "$path_conda/etc/profile.d/conda.sh"
|
|
|
|
|
2020-09-25 11:50:43 +00:00
|
|
|
condaexec="conda"
|
|
|
|
pythonexec="python"
|
2020-09-22 13:26:18 +00:00
|
|
|
|
2020-09-26 08:09:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-22 13:27:34 +00:00
|
|
|
echo '
|
2020-09-22 13:26:18 +00:00
|
|
|
|
2020-09-26 08:09:01 +00:00
|
|
|
5) creating virtual environment...
|
2020-09-22 13:26:18 +00:00
|
|
|
|
2020-09-22 13:27:34 +00:00
|
|
|
'
|
2020-09-25 12:37:13 +00:00
|
|
|
path_venv="$path_repo/venv"
|
2020-09-22 13:26:18 +00:00
|
|
|
|
2020-09-25 11:33:02 +00:00
|
|
|
# cd $path_komrade
|
|
|
|
cd $path_repo
|
|
|
|
echo "Now using python 1: `which python`"
|
2020-09-25 12:49:38 +00:00
|
|
|
$condaexec create -y -p "$path_venv" python=3.7 cartopy pip virtualenv
|
2020-09-25 13:17:03 +00:00
|
|
|
|
|
|
|
#$condaexec activate "$path_venv"
|
|
|
|
|
|
|
|
|
2020-09-25 11:33:02 +00:00
|
|
|
echo "Now using python 2: `which python`"
|
|
|
|
# $pythonexec -m pip install virtualenv
|
2020-09-25 12:10:13 +00:00
|
|
|
# $pythonexec -m virtualenv venv
|
|
|
|
# . venv/bin/activate
|
2020-09-25 11:33:02 +00:00
|
|
|
echo "Now using python 3: `which python`"
|
2020-09-22 13:45:46 +00:00
|
|
|
|
2020-09-22 13:27:34 +00:00
|
|
|
python -m pip install -r requirements.txt
|
2020-09-22 10:02:40 +00:00
|
|
|
|
2020-09-22 13:23:49 +00:00
|
|
|
echo '
|
2020-09-22 10:02:40 +00:00
|
|
|
|
2020-09-26 08:09:01 +00:00
|
|
|
6) adding komrade bin folder to path
|
2020-09-22 10:02:40 +00:00
|
|
|
|
2020-09-22 13:23:49 +00:00
|
|
|
'
|
2020-09-14 15:59:11 +00:00
|
|
|
|
2020-09-27 12:08:32 +00:00
|
|
|
commands_app="
|
2020-09-28 13:17:52 +00:00
|
|
|
source $path_conda/etc/profile.d/conda.sh\n
|
|
|
|
export PATH=\"$path_conda/bin:\$PATH\"\n
|
|
|
|
conda activate $path_venv\n
|
|
|
|
python -m pip install -r $path_repo/requirements.txt\n
|
|
|
|
python $path_repo/komrade/app/main.py\n
|
2020-09-27 12:08:32 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export PATH="$path_bin:$PATH"
|
|
|
|
bashline="export PATH=\"$path_bin:\$PATH\" # komrade installation"
|
|
|
|
bashfn="~/.bashrc"
|
|
|
|
|
|
|
|
# add to bashrc?
|
|
|
|
if grep -Fxq "$bashline" "$bashfn"
|
|
|
|
then
|
|
|
|
# code if found
|
|
|
|
echo "setting already in $bashfn: $bashline"
|
|
|
|
else
|
|
|
|
# code if not found
|
|
|
|
echo "$bashline" >> "$bashfn"
|
|
|
|
fi
|
2020-09-22 10:02:40 +00:00
|
|
|
|
2020-09-22 13:36:20 +00:00
|
|
|
|
2020-09-28 13:17:52 +00:00
|
|
|
echo -e "Now run Komrade with:
|
2020-09-22 10:02:40 +00:00
|
|
|
|
2020-09-22 13:23:49 +00:00
|
|
|
komrade-app [GUI interface -- alpha]
|
2020-09-22 11:16:30 +00:00
|
|
|
|
2020-09-26 08:09:01 +00:00
|
|
|
If that doesn't work, try running this series of comands:
|
|
|
|
|
2020-09-27 12:08:32 +00:00
|
|
|
$commands_app
|
2020-09-26 08:09:01 +00:00
|
|
|
|
2020-09-22 13:23:49 +00:00
|
|
|
"
|
2020-09-28 13:17:52 +00:00
|
|
|
|
|
|
|
# run?
|
|
|
|
. $path_bin/komrade-app
|
|
|
|
|
|
|
|
if [ "$machine" = "Mac" ]
|
|
|
|
then
|
2020-09-28 13:55:01 +00:00
|
|
|
cd /Applications
|
|
|
|
unzip "$path_bin/Komrade.app.zip"
|
|
|
|
# cp "$path_bin/Komrade.app" /Applications/
|
2020-09-28 13:17:52 +00:00
|
|
|
|
|
|
|
echo "You may run the app by looking for 'Komrade.app' in your /Applications folder."
|
|
|
|
fi
|