Created
March 7, 2018 14:26
-
-
Save arthuroe/f35c8f2036da48d6299a403066d0c3fb to your computer and use it in GitHub Desktop.
script to automatically setup project..(Under refinement)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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