File: snac2.postinst

package info (click to toggle)
snac2 2.89-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,800 kB
  • sloc: ansic: 22,703; sh: 179; makefile: 69; python: 34
file content (43 lines) | stat: -rwxr-xr-x 1,184 bytes parent folder | download | duplicates (5)
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
#!/bin/sh

set -e

USER=debian-snac
GROUP=debian-snac
BASEDIR=/var/lib/snac2

case "$1" in
    configure)
        # TODO: Check if user/group can be declarative.
        if ! getent group $GROUP >/dev/null; then
            addgroup --system --quiet $GROUP
        fi

        if ! getent passwd $USER >/dev/null; then
            adduser --system --quiet --ingroup $GROUP \
                    --no-create-home --home $BASEDIR $USER
        fi

        # Initialize data storage if needed.
        if [ ! -e "$BASEDIR/server.json" ]; then
            TEMPDIR=$(runuser -u $USER -- mktemp --directory --tmpdir=/tmp)
            TEMPBASEDIR="$TEMPDIR/snac2"
            printf '\n\nlocalhost\n/social\n' | \
                runuser -u $USER -- snac init "$TEMPBASEDIR"
            cp -a "$TEMPBASEDIR/." "$BASEDIR"
            rm -rf "$TEMPDIR"
        fi

        # If apache2 is installed, then enable modules.
        if [ -e /usr/share/apache2/apache2-maintscript-helper ]
        then (
            . /usr/share/apache2/apache2-maintscript-helper
            apache2_invoke enmod proxy
            apache2_invoke enmod proxy_http
        ) fi
        ;;
esac

#DEBHELPER#

exit 0