-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathpython3-patchman.postinst
More file actions
62 lines (48 loc) · 2.27 KB
/
python3-patchman.postinst
File metadata and controls
62 lines (48 loc) · 2.27 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
60
61
62
#!/bin/sh -e
#DEBHELPER#
if [ "$1" = "configure" ] ; then
if ! grep /usr/lib/python3/dist-packages/patchman /etc/apache2/conf-available/patchman.conf >/dev/null 2>&1 ; then
sed -i -e "s/^\(Define patchman_pythonpath\).*/\1 \/usr\/lib\/python3\/dist-packages/" \
/etc/apache2/conf-available/patchman.conf
fi
. /usr/share/apache2/apache2-maintscript-helper
apache2_invoke enconf patchman.conf
patchman-set-secret-key
chown www-data /etc/patchman/local_settings.py
mkdir -p /var/lib/patchman/db
patchman-manage collectstatic --noinput
patchman-manage makemigrations
patchman-manage migrate --run-syncdb --fake-initial
sqlite3 /var/lib/patchman/db/patchman.db 'PRAGMA journal_mode=WAL;'
chown -R www-data:www-data /var/lib/patchman
adduser --system --group patchman-celery
usermod -a -G www-data patchman-celery
chown root:patchman-celery /etc/patchman/celery.conf
chmod 640 /etc/patchman/celery.conf
chmod g+w /var/lib/patchman /var/lib/patchman/db /var/lib/patchman/db/patchman.db
WORKER_COUNT=1
if [ -f /etc/patchman/celery.conf ]; then
. /etc/patchman/celery.conf
WORKER_COUNT=${CELERY_WORKER_COUNT:-1}
fi
if [ -d /run/systemd/system ]; then
systemctl daemon-reload >/dev/null || true
for i in $(seq 1 "${WORKER_COUNT}"); do
deb-systemd-helper enable "patchman-celery-worker@$i.service" >/dev/null || true
deb-systemd-invoke start "patchman-celery-worker@$i.service" >/dev/null || true
done
active_instances=$(systemctl list-units --type=service --state=active "patchman-celery-worker@*" --no-legend | awk '{print $1}')
for service in $active_instances; do
inst_num=$(echo "$service" | cut -d'@' -f2 | cut -d'.' -f1)
if [ "$inst_num" -gt "${WORKER_COUNT}" ]; then
deb-systemd-invoke stop "$service" >/dev/null || true
deb-systemd-helper disable "$service" >/dev/null || true
fi
done
deb-systemd-helper enable "patchman-celery-beat.service" >/dev/null || true
deb-systemd-invoke start "patchman-celery-beat.service" >/dev/null || true
fi
echo
echo "Remember to run 'patchman-manage createsuperuser' to create a user."
echo
fi