-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostinst-python-django-set-env
More file actions
59 lines (48 loc) · 1.55 KB
/
postinst-python-django-set-env
File metadata and controls
59 lines (48 loc) · 1.55 KB
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
case "$1" in
"configure"|"reconfigure")
. /usr/share/debconf/confmodule
db_version 2.0
# # # # # # # # # # ## # # # # # ## # ##
# Now populate the settings of the package
if [ -f "/etc/#PACKAGE#/env" ]; then
/bin/rm -fr "/etc/#PACKAGE#/env"
fi
for VARIABLE_NAME in `/usr/bin/debconf-show #PACKAGE# | grep 'DJANGO_' | /usr/bin/awk '{print $2}' | /usr/bin/cut -d'/' -f2 | /usr/bin/tr -d ':'`;
do
db_get django/${VARIABLE_NAME}
/bin/cat >> /etc/#PACKAGE#/env <<EOF
${VARIABLE_NAME}='${RET}'
EOF
done
cat > /etc/#PACKAGE#/uwsgi.ini <<EOF
[uwsgi]
socket = 0.0.0.0:3031
module = #PACKAGE#.wsgi
home = /usr/share/python/#PACKAGE#
uid = #PACKAGE#
gid = #PACKAGE#
chmod = 775
logger = syslog:local4
processes = 4
master = 1
EOF
cat > /etc/rsyslog.d/#PACKAGE#.conf <<EOF
# Configuration file for the django application: #PACKAGE#
# this is used by the local5 -> 7 facility
\$ModLoad imuxsock
local5.debug /var/log/#PACKAGE#.log;RSYSLOG_TraditionalFileFormat
local5.warning /var/log/#PACKAGE#.err;RSYSLOG_TraditionalFileFormat
EOF
# add the user
adduser --system --group --quiet --no-create-home \
--disabled-login --force-badname #PACKAGE#
usermod -a -G www-data #PACKAGE#
usermod -a -G #PACKAGE# www-data
if [ -d "/var/#PACKAGE#/" ];
then
chown -R www-data:www-data "/var/#PACKAGE#/"
fi
# (re)starting app
systemctl restart rsyslog
;;
esac