summaryrefslogtreecommitdiffstats
path: root/postinst
blob: 3d1b1cf69dbfe8bb2513bbb89a17893c302bde26 (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
#!/bin/sh
#
# Postinst script for mandaye-meyzieu
#

set -e

NAME=mandaye-meyzieu
USER=$NAME
GROUP=$NAME
HOME=/var/lib/$NAME

case "$1" in
    configure)
        if ! getent group $GROUP > /dev/null 2>&1; then
            echo -n "Adding group $GROUP.."
            addgroup --quiet --system $GROUP
            echo "..done"
        fi
        if ! getent passwd $USER > /dev/null 2>&1; then
            echo -n "Adding user $USER.."
            adduser --quiet --system --gecos "Mandaye Meyzieu daemon" \
                    --ingroup $GROUP \
                    --no-create-home --home $HOME \
                    $USER
            echo "..done"
        fi
        if [ ! -f /etc/mandaye-meyzieu/certs/saml.crt -a ! -f /etc/mandaye-meyzieu/certs/saml.key ]; then
            echo -n "Generating key material..." >&2
            openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out /etc/mandaye-meyzieu/certs/saml.key >&2
            openssl req -x509 -new -out /etc/mandaye-meyzieu/certs/saml.crt -subj '/CN=whocares' -key /etc/mandaye-meyzieu/certs/saml.key -days 3650 >&2
            chown root:$GROUP /etc/mandaye-meyzieu/certs/saml.crt /etc/mandaye-meyzieu/certs/saml.key
            chmod 640 /etc/mandaye-meyzieu/certs/saml.crt /etc/mandaye-meyzieu/certs/saml.key
            echo "..done" >&2
        fi

        echo -n "Fixing permissions.."
        chown $USER:$GROUP /var/lib/$NAME /var/run/$NAME /var/log/$NAME
        chown $USER:$GROUP /var/lib/$NAME/data /var/lib/$NAME/sessions
        echo "..done"

        if [ -z "$2" ]; then
            echo "Please create your database :"
            echo "su $USER -p -c '/usr/bin/rp_meyzieu_manager --createdb'"
        fi
        ;;

    reconfigure)
        ;;

    abort-upgrade|abort-remove|abort-deconfigure)
        ;;

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0