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

168 lines
3.0 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?
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
if [ ! -d "$path_komrade" ]
then
mkdir -p $path_komrade
echo "created $path_komrade"
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
else
git clone https://github.com/Komrade/Komrade.git
fi
4 years ago
mv Komrade code
fi
else
cd $path_komrade
4 years ago
curl -s -LO https://github.com/Komrade/Komrade/archive/master.zip
4 years ago
unzip master.zip
rm master.zip
4 years ago
cp -rT Komrade-master code
4 years ago
rm -r Komrade-master
fi
cd $path_komrade
4 years ago
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
4 years ago
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..."
4 years ago
curl -s https://pyenv.run | bash
4 years ago
echo "installing python 3.7.3..."
4 years ago
4 years ago
#eval "$(pyenv init -)"
$HOME/.pyenv/bin/pyenv install 3.7.3
4 years ago
fi
fi
4 years ago
4 years ago
cd $path_komrade
4 years ago
echo '
4) creating virtual environment...
'
4 years ago
## get the pyenv python if possible
if command -v $HOME/.pyenv/bin/pyenv &> /dev/null
4 years ago
then
# activate right version
4 years ago
$HOME/.pyenv/bin/pyenv install 3.7.3 -s
$HOME/.pyenv/bin/pyenv local 3.7.3
# activate right python exec in terminal
4 years ago
# eval "$($HOME/.pyenv/bin/pyenv init -)"
4 years ago
pythonexec="$HOME/.pyenv/shims/python"
else
pythonexec="python3"
4 years ago
fi
4 years ago
cd $path_repo
4 years ago
echo "Using python exec: $pythonexec"
echo "Using Python version:"
$pythonexec --version
4 years ago
VENV="venv"
4 years ago
4 years ago
# get pip
curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py
4 years ago
$pythonexec get-pip.py
4 years ago
4 years ago
$pythonexec -m pip install virtualenv
$pythonexec -m virtualenv $VENV
4 years ago
. $VENV/bin/activate
python3 -m pip install -U pip setuptools wheel
python3 -m pip install -r requirements.txt
export PATH="$path_repo/bin:$PATH"
4 years ago
4 years ago
echo '
4 years ago
5) adding komrade bin folder to path
4 years ago
'
4 years ago
echo "
# komrade
export PATH=\"$path_repo/bin:\$PATH\"
" >> ~/.bashrc