summaryrefslogtreecommitdiffstats
path: root/packaging/deb/meshbay-hub/DEBIAN/postinst
blob: 48921f2d02e70990fb3b4aa82b94740af9d09f46 (plain) (blame)
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
#!/bin/sh
set -e

case "$1" in
    configure)
        # Create service account
        if ! getent group meshbay >/dev/null 2>&1; then
            addgroup --system meshbay
        fi
        if ! getent passwd meshbay >/dev/null 2>&1; then
            adduser --system --ingroup meshbay --home /var/lib/meshbay \
                    --no-create-home --disabled-password \
                    --gecos "MeshBay service account" meshbay
        fi

        # Create data directory
        install -d -o meshbay -g meshbay -m 750 /var/lib/meshbay/hub
        install -d -o meshbay -g meshbay -m 750 /var/log/meshbay

        # Enable and start service
        if [ -d /run/systemd/system ]; then
            systemctl daemon-reload || true
            systemctl enable meshbay-hub.service || true
            systemctl start meshbay-hub.service || true
        fi
        ;;
esac

#DEBHELPER#