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

145 lines
2.4 KiB
Plaintext

4 years ago
#!/bin/bash
4 years ago
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?
echo "where should komrade live?"
read -p "[~/komrade] " path_komrade
if [ -z "$path_komrade" ]
then
path_komrade="`realpath ~/komrade`"
fi
# echo "
# $path_komrade
# "
# exit
if [ ! -d "$path_komrade" ]
then
mkdir -p $path_komrade
echo "created $path_komrade"
fi
echo '
4 years ago
2) downloading Komrade...
4 years ago
'
path_repo="$path_komrade/code"
if ! command -v git &> /dev/null
then
4 years ago
if [-d "$path_repo" ]
4 years ago
then
cd $path_repo
git pull
else
cd $path_komrade
git clone https://github.com/Komrade/Komrade.git
mv Komrade code
fi
else
cd $path_komrade
curl -LO https://github.com/Komrade/Komrade/archive/master.zip
unzip master.zip
rm master.zip
cp -r Komrade-master code
rm -r Komrade-master
fi
cd $path_komrade
4 years ago
echo '
3) setting up python...
'
4 years ago
# if ! command -v pyenv &> /dev/null
4 years ago
if [ ! -d "$HOME/.pyenv" ]
4 years ago
then
echo "pyenv not installed. install?"
read -p "[Y/n] " pyenv_yn
if [ ! pyenv_yn=="n" ]; then
4 years ago
echo "Not installing pyenv."
4 years ago
else
4 years ago
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
4 years ago
echo "installing..."
curl https://pyenv.run | bash
echo "installing python 3.7.3..."
4 years ago
4 years ago
#eval "$(pyenv init -)"
pyenv install 3.7.3
pyenv local 3.7.3
fi
fi
cd $path_komrade
4 years ago
echo '
4) creating virtual environment...
'
4 years ago
## the pyenv way
if command -v pyenv &> /dev/null
then
cd $path_repo
4 years ago
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
4 years ago
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"
4 years ago
echo '
5) adding bin folder to path
'
4 years ago
echo "
# komrade
export PATH=\"$path_repo/bin:\$PATH\"
" >> ~/.bashrc