aboutsummaryrefslogtreecommitdiffstats
path: root/debian/postinst
blob: bfd3a53c4002e3f7422dcdac77795445ce70e9de (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
#!/bin/sh
#DEBHELPER#

set -e

case "$1" in
    configure)
       SERVER_HOME=/var/lib/rspamd
       SERVER_RUN=/var/run/rspamd
       SERVER_LOG=/var/log/rspamd
       SERVER_USER=rspamd
       SERVER_NAME="Rspamd spam filtering system"

       adduser --quiet \
               --system \
               --group \
               --home $SERVER_HOME \
               --no-create-home \
               --disabled-login \
               --gecos "$SERVER_NAME" \
               $SERVER_USER

       # 2. create homedir if not existing
       test -d $SERVER_RUN || mkdir $SERVER_RUN

       # 5. adjust file and directory permissions
       if ! dpkg-statoverride --list $SERVER_HOME >/dev/null
       then
           chown -R $SERVER_USER:$SERVER_GROUP $SERVER_HOME $SERVER_LOG $SERVER_RUN
           chmod u=rwx,g=rx,o= $SERVER_HOME
           chmod u=rwx,g=rx,o=rx $SERVER_RUN
           chmod u=rwx,g=rx,o=rx $SERVER_LOG
       fi
    ;;

    abort-*)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

exit 0