forked from MisterCyp/RuFy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·147 lines (119 loc) · 4.23 KB
/
install.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/bash
INSTALLDIR=$(readlink -f $(dirname $0))
USER=rufy
GROUP=web
VIRTUALDIR="venv"
mkdir -p ${INSTALLDIR}/log/
exec 2>${INSTALLDIR}/log/install.log
echo "
#########################################
##### Installation des dépendances : ####
#########################################
"
echo "
####################################
##### aptitude ####
####################################
"
apt-get install -y aptitude
echo "
####################################
##### python 2.7 ####
####################################
"
aptitude install -y python2.7
echo "
####################################
##### python-virtualenv ####
####################################
"
aptitude install -y python-virtualenv
echo "
####################################
##### python-dev ####
####################################
"
aptitude install -y python-dev
echo "
####################################
##### supervisor ####
####################################
"
aptitude install -y supervisor
echo "
###########################################################################
##### Création de l'utilisateur $USER associé au groupe $GROUP ####
###########################################################################
"
groupadd $GROUP
useradd --system --gid $GROUP --shell /bin/bash --home $INSTALLDIR $USER
echo "
###########################################################################
##### Configuration de supervisor pour lancer automatique RuFy ####
###########################################################################
"
cd $INSTALLDIR
touch config/${USER}_SUPERVISOR.conf
echo "[program:rufy]
command = ${INSTALLDIR}/gunicorn_start ; Command to start app
user = ${USER} ; User to run as
stdout_logfile = ${INSTALLDIR}/log/gunicorn_supervisor.log ; Where to write log messages
redirect_stderr = true ; Save stderr in the same log
environment=LANG=fr_FR.UTF-8,LC_ALL=fr_FR.UTF-8 ; Set UTF-8 as default encoding" >> config/${USER}_SUPERVISOR.conf
cp config/${USER}_SUPERVISOR.conf /etc/supervisor/conf.d/${USER}_SUPERVISOR.conf
touch log/gunicorn_supervisor.log
supervisorctl reread
supervisorctl update
echo "
###########################################################################
##### Copie de la base de donnée initiale ####
###########################################################################
"
mkdir -v ${INSTALLDIR}/db
cp -v ${INSTALLDIR}/config/db-init.sqlite3 ${INSTALLDIR}/db/db.sqlite3
echo "
###########################################################################
##### Configuration de Python pour RuFy avec virtualenv ####
###########################################################################
"
mkdir -p $VIRTUALDIR
echo "
####################################################
$USER devient propriétaire du dossier $INSTALLDIR :
####################################################
"
chown -R ${USER}:users $INSTALLDIR
chmod -R g+w $INSTALLDIR
chmod +x ${INSTALLDIR}/gunicorn_start
echo "
####################################################
Creation du dossier virtualvenv dans $VIRTUALDIR
####################################################
"
su $USER -c "virtualenv -p /usr/bin/python2.7 $VIRTUALDIR"
echo "
#######################################
Activation du dossier virtualvenv
#######################################
"
source ${VIRTUALDIR}/bin/activate
echo "
#####################################
Installation des requirements
#####################################
"
pip install -r requirements.txt
pip install setproctitle
echo "
#####################################
Migrations Django
#####################################
"
python manage.py collectstatic_js_reverse
python manage.py makemigrations
python manage.py migrate
echo "
################################################################################################################
Installation réussi : Il reste la configuration de Nginx pour rediriger les requetes vers 127.0.0.1:8000
################################################################################################################
"