aboutsummaryrefslogtreecommitdiffstats
path: root/debian/osmo-stp.postinst
blob: 94fb408c5e15d5747fe16ee6ba6044c01737e402 (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
#!/bin/sh -e
# Create 'osmocom' user and group (if it doesn't exist yet) and adjust permissions
# of directories which are not automatically adjusted by systemd from previous (root-owned)
# install.

# N. B: the user is intentionally NOT removed during package uninstall:
# see https://wiki.debian.org/AccountHandlingInMaintainerScripts for reasoning.
chperms() {
	# chperms <user> <group> <perms> <file>
	if ! OVERRIDE=`dpkg-statoverride --list $4 2>&1`; then
		if [ -e $4 ]; then
			chown $1:$2 $4
			chmod $3 $4
		fi
	fi
}

case "$1" in
  configure)
    if ! getent passwd osmocom > /dev/null; then
        adduser --quiet \
                --system \
                --group \
                --no-create-home \
                --disabled-password \
                --home /var/lib/osmocom \
                --gecos "Open Source Mobile Communications" \
                osmocom
    fi
# Set permissions according to https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
    chperms osmocom osmocom 0660 /etc/osmocom/osmo-stp.cfg
    chperms root osmocom 2775 /etc/osmocom

  ;;
esac

# dh_installdeb(1) will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#