]> git.0d.be Git - panikdb.git/blob - debian/stamina.postinst
debian: add user to audio group as required for stamina
[panikdb.git] / debian / stamina.postinst
1 #! /bin/sh
2
3 set -e
4
5 NAME="panikdb"
6 USER=$NAME
7 GROUP=$NAME
8 CONFIG_DIR="/etc/$NAME"
9 MANAGE_SCRIPT="/usr/bin/$NAME-manage"
10
11 case "$1" in
12   configure)
13
14     # make sure the administrative user exists
15     if ! getent passwd $USER >/dev/null; then
16       adduser --disabled-password  --quiet --system \
17         --no-create-home --home /var/lib/$NAME \
18         --gecos "$NAME user" --group $USER
19       # add to audio group as required for stamina, it can be removed if
20       # not necessary and won't be automatically added back.
21       adduser $USER audio
22     fi
23     # ensure dirs ownership
24     chown $USER:$GROUP /var/log/$NAME
25     chown $USER:$GROUP /var/log/stamina
26     chown $USER:$GROUP /var/lib/$NAME/media
27     chown $USER:$GROUP /var/lib/$NAME/static
28     # create a secret file
29     SECRET_FILE=$CONFIG_DIR/secret
30     if [ ! -f $SECRET_FILE ]; then
31         echo -n "Generating Django secret..." >&2
32         cat /dev/urandom | tr -dc [:alnum:]-_\!\%\^:\; | head -c70 > $SECRET_FILE
33         chown root:$GROUP $SECRET_FILE
34         chmod 0440 $SECRET_FILE
35     fi
36   ;;
37
38   abort-upgrade|abort-remove|abort-deconfigure|triggered)
39   ;;
40
41   *)
42     echo "postinst called with unknown argument \`$1'" >&2
43     exit 1
44   ;;
45 esac
46
47 #DEBHELPER#
48
49 exit 0