2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-17 21:25:37 +00:00
Comrad/script/install

156 lines
2.7 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
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
else
git clone https://github.com/Komrade/Komrade.git
fi
2020-09-14 15:59:11 +00:00
mv Komrade code
fi
else
cd $path_komrade
curl -LO https://github.com/Komrade/Komrade/archive/master.zip
unzip master.zip
rm master.zip
2020-09-14 16:52:59 +00:00
cp -rT Komrade-master code
2020-09-14 15:59:11 +00:00
rm -r Komrade-master
fi
cd $path_komrade
2020-09-14 16:42:03 +00:00
2020-09-14 16:01:38 +00:00
echo '
3) setting up python...
'
2020-09-14 15:59:11 +00:00
# if ! command -v pyenv &> /dev/null
2020-09-14 16:05:50 +00:00
if [ ! -d "$HOME/.pyenv" ]
2020-09-14 15:59:11 +00:00
then
echo "pyenv not installed. install?"
read -p "[Y/n] " pyenv_yn
2020-09-17 05:01:59 +00:00
if [ "$pyenv_yn" = "n" ]; then
2020-09-14 16:05:50 +00:00
echo "Not installing pyenv."
2020-09-14 15:59:11 +00:00
else
2020-09-14 16:05:50 +00:00
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
2020-09-14 15:59:11 +00:00
echo "installing..."
curl https://pyenv.run | bash
echo "installing python 3.7.3..."
2020-09-14 16:05:50 +00:00
2020-09-14 15:59:11 +00:00
#eval "$(pyenv init -)"
pyenv install 3.7.3
pyenv local 3.7.3
fi
fi
2020-09-14 16:42:03 +00:00
2020-09-14 15:59:11 +00:00
cd $path_komrade
2020-09-14 16:01:38 +00:00
echo '
4) creating virtual environment...
'
2020-09-14 15:59:11 +00:00
## the pyenv way
if command -v pyenv &> /dev/null
then
cd $path_repo
2020-09-14 16:05:50 +00:00
pyenv install --skip-existing
#VENV="${PWD##*/}.venv"
VENV="venv"
VENV=${VENV#-}
python -m venv $VENV
. $VENV/bin/activate
python -m pip install -U pip setuptools wheel
python -m pip install -r requirements.txt
2020-09-14 15:59:11 +00:00
else
cd $path_repo
python -m pip install virtualenv
python -m virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
fi
export PATH="$path_repo/bin:$PATH"
2020-09-14 16:42:03 +00:00
2020-09-14 16:01:38 +00:00
echo '
2020-09-14 16:42:03 +00:00
5) adding komrade bin folder to path
2020-09-14 16:01:38 +00:00
'
2020-09-14 15:59:11 +00:00
echo "
# komrade
export PATH=\"$path_repo/bin:\$PATH\"
" >> ~/.bashrc