blob: 4d850ac27018d3d406c54e237e15c03b389775c1 (
plain)
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
|
#!/bin/sh
set -e
set -x
DATA_DIR=/srv/ishtar
INSTANCES_FILE=/etc/ishtar/instances
case "$1" in
configure)
mkdir -p /etc/ishtar/
if [ ! -f /etc/ishtar/config ]; then
cp /usr/share/python3-django-ishtar/install/config.template /etc/ishtar/config ;
fi
instances="$( (cat $INSTANCES_FILE 2>/dev/null || true) | xargs )"
if [ -n "$instances" ]; then
echo "updading instances found in $INSTANCES_FILE: $instances"
for instance in $instances; do
# The upgrade procedure below was built from the "update"
# target and its dependencies in the upstream Makefile:
echo "updating $instance"
cd $DATA_DIR/$instance
# from "syncdb" target:
python manage.py syncdb --noinput
python manage.py migrate
# from "compilemessages" target:
#
# NOTE: Instead of hardcoding an "apps" variable here, let's
# look at candidates with find, and check whether each of
# them indeed contains PO files as a second check:
maybe_localized=$(cd $DATA_DIR; find -maxdepth 2 -name 'locale')
for candidate in $maybe_localized; do
if find $DATA_DIR/$candidate -name '*.po' >/dev/null 2>&1; then
# Really looks like a valid app, let's strip the last
# directory, cd into it, and compile messages using
# the instance's manage.py script:
app=${candidate%%/locale}
(cd $DATA_DIR/$app; python $DATA_DIR/$instance/manage.py compilemessages)
fi
done
# XXX: Doing this only once is likely sufficient, so
# we could remember having performed that update while
# taking care of the first instance, to avoid
# extraneous reruns?
# from "collectstatic" target:
python manage.py collectstatic --noinput
echo "updating $instance: OK"
done
echo "updating all instances: OK"
# the assumption is that nginx and uwsgi were configured
# through ishtar-prepare-instance, so let's restart them
# unconditionally:
invoke-rc.d uwsgi restart
invoke-rc.d nginx restart
echo "restarting uwsgi and nginx: OK"
else
echo "found no instances to upgrade in $INSTANCES_FILE"
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
|