forked from imunizaga/nosotrosusamos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickstart.sh
executable file
·122 lines (101 loc) · 2.94 KB
/
quickstart.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
INSTALL_APTITUDE=true
INSTALL_PIP=true
INSTALL_HEROKU=false
while getopts “ahp” OPTION
do
case $OPTION in
a)
echo "only install aptitude"
INSTALL_APTITUDE=true
INSTALL_PIP=false
INSTALL_HEROKU=false
;;
p)
echo "only pip install"
INSTALL_APTITUDE=false
INSTALL_PIP=true
INSTALL_HEROKU=false
;;
h)
echo "only heroku install"
INSTALL_APTITUDE=false
INSTALL_PIP=false
INSTALL_HEROKU=true
;;
?)
echo "fail"
exit
;;
esac
done
if $INSTALL_APTITUDE ; then
# sudo install virtual env and other things with aptitude
# Install base packages
yes | sudo apt-get install python-pip python-virtualenv python-dev
echo "Are you going to use mysql for your database? [N/y]"
read INSTALL_MYSQL
if [[ "$INSTALL_MYSQL" == "y" ]]
then
# Install mysql related packages
yes | sudo apt-get install libmysqlclient-dev python-mysqldb
else
echo "Are you going to use postgre for your database? [N/y]"
read INSTALL_POSTGRE
if [[ "$INSTALL_POSTGRE" == "y" ]]
then
./install/postgres.sh
fi
fi
# set a new virtual environment
virtualenv .env
fi
if $INSTALL_PIP ; then
# activate the environment
source .env/bin/activate
# install setuptools
pip install --upgrade setuptools
# install pip requiredments in the virtual environment
.env/bin/pip install --download-cache=~/.pip-cache --requirement install/requirements.pip
if [[ "$INSTALL_MYSQL" == "y" ]] ; then
pip install mysql-python
fi
if [[ "$INSTALL_POSTGRE" == "y" ]]
then
pip install psycopg2
fi
fi
# update pip database requirements
source .env/bin/activate
if [[ "$INSTALL_MYSQL" == "y" ]]
then
pip install MySQL-python
elif [[ "$INSTALL_POSTGRE" == "y" ]]
then
pip install psycopg2
fi
# HEROKU
if $INSTALL_HEROKU ; then
# activate the environment
source .env/bin/activate
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
heroku login
pip install psycopg2 dj-database-url
pip freeze > requirements.txt
pip uninstall psycopg2 dj-database-url
echo "web: python manage.py runserver 0.0.0.0:$PORT --noreload" > Procfile
echo "Would you like to create a new heroku repo? [N/y]"
read CREATE_REPO
if [[ "$CREATE_REPO" == "y" ]]
then
heroku create
fi
echo "You should now commit the requirements.txt file."
echo "Then deploy to heroku: git push heroku master"
fi
# create the local_settings file if it does not exist
if [ ! -f ./config/local_settings.py ] ; then
cp config/local_settings.py.default config/local_settings.py
EXP="s/django-db/${PWD##*/}/g"
echo $i|sed -i $EXP config/local_settings.py
fi