Skip to content

Instantly share code, notes, and snippets.

@arthuroe
Created March 7, 2018 14:26
Show Gist options
  • Save arthuroe/f35c8f2036da48d6299a403066d0c3fb to your computer and use it in GitHub Desktop.
Save arthuroe/f35c8f2036da48d6299a403066d0c3fb to your computer and use it in GitHub Desktop.
script to automatically setup project..(Under refinement)
#!/bin/bash
link='Your project url here'
if [ "$link" ];then
cd ~/
[ -d test_proj ] || mkdir test_proj
cd ~/test_proj
directory=${link##*/}
if [ -d "$directory" ]; then
echo "Project folder already exists"
else
git clone $link
echo 'Successfully cloned repo'
cd "$directory"
fi
fi
# Check for python and install if it doesn't exist
var=$(python3 -V)
if ! which $var &> /dev/null;then
brew install python3
else
echo "Python already installed"
fi
# Check for pip and install if it doesn't exist
var=$(pip -V)
if ! which $var &> /dev/null;then
sudo easy_install pip
else
echo "Pip already installed"
fi
# Check for redis-server and install if it doesn't exist
var=$(redis-server -v)
if ! which $var &> /dev/null;then
brew install redis
else
echo "Python already installed"
fi
# Check for postgres and install if it doesn't exist
var=$(psql --version)
if ! which $var &> /dev/null; then
brew install postgresql
pg_ctl -D /usr/local/var/postgres start && brew services start postgresq
fi
# Setup virtual envs
[ -d .virtualenvs ] || mkdir .virtualenvs
python3 -m venv ~/.virtualenvs/test_env
source ~/.virtualenvs/test_env/bin/activate
cd ~/test_proj/$directory
ls
pip install -r requirements.txt
# Create database and user
read -p "Enter database user: " user
read -sp "Enter user password: " secret
if [ "$user" ] && ["$secret"];then
sudo psql -c "CREATE ROLE "$user" PASSWORD '$secret' CREATEDB CREATEROLE INHERIT LOGIN;" -U postgres
sudo psql -c "create database learning_map;" -U postgres
export $(cat .env)
flask db upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment