2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-11 13:10:45 +00:00
Comrad/script/install

192 lines
3.8 KiB
Plaintext
Raw Normal View History

2020-09-14 15:59:11 +00:00
#!/bin/bash
2020-09-14 13:38:27 +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`"
read -p "[$path_komrade_default] " path_komrade
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-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
echo "Use HTTPS or SSH for git?"
read -p "[HTPS/ssh] " git_method
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-14 16:42:03 +00:00
2020-09-14 16:01:38 +00:00
echo '
3) setting up python...
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-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-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-22 13:27:34 +00:00
fi
2020-09-22 13:36:20 +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"
condaexec="conda"
pythonexec="python"
2020-09-22 13:26:18 +00:00
2020-09-22 13:27:34 +00:00
echo '
2020-09-22 13:26:18 +00:00
2020-09-22 13:27:34 +00:00
4) 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 12:10:13 +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-22 13:23:49 +00:00
5) 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-22 13:23:49 +00:00
echo "
2020-09-14 15:59:11 +00:00
2020-09-22 13:23:49 +00:00
# komrade
export PATH=\"$path_repo/bin:\$PATH\"
2020-09-22 10:02:40 +00:00
2020-09-22 13:23:49 +00:00
" >> ~/.bashrc
2020-09-22 13:36:20 +00:00
2020-09-22 13:27:34 +00:00
export PATH="$path_repo/bin:$PATH"
2020-09-22 10:02:40 +00:00
2020-09-22 13:23:49 +00:00
echo "Now run Komrade with:
2020-09-22 10:02:40 +00:00
2020-09-22 13:23:49 +00:00
komrade-cli [CLI interface -- beta]
komrade-app [GUI interface -- alpha]
2020-09-22 11:16:30 +00:00
2020-09-22 13:23:49 +00:00
"