File: postsrsd.postinst

package info (click to toggle)
postsrsd 1.5-2%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 416 kB
  • sloc: ansic: 1,584; sh: 201; makefile: 22
file content (48 lines) | stat: -rwxr-xr-x 1,615 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

CONFIGFILE=/etc/default/postsrsd
set -e
. /usr/share/debconf/confmodule

if [ "$1" = "configure" ]; then
	if [ ! -f /etc/postsrsd.secret ]; then
		echo "postsrsd: Generating initial /etc/postsrsd.secret" >&2
		( umask 0077 ; dd if=/dev/urandom bs=24 count=1 2>/dev/null | base64 -w0 > /etc/postsrsd.secret )
	fi

	# We'll only write the configured domain to the config file if it doesn't
	# exist yet, or we're called by dpkg-reconfigure.
	db_get postsrsd/domain; DOMAIN="$RET"

	if [ ! -e $CONFIGFILE ]; then
		cp -a -f /usr/share/postsrsd/postsrsd.template $CONFIGFILE.tmp
		# strip comment from SRS_DOMAIN and write configured domain to config file
		sed -i "s/^#SRS_DOMAIN=.*/SRS_DOMAIN=$DOMAIN/" $CONFIGFILE.tmp
		mv -f $CONFIGFILE.tmp $CONFIGFILE
	fi

	if [ "$DEBCONF_RECONFIGURE" = "1" ]; then
		cp -a -f $CONFIGFILE $CONFIGFILE.tmp
		sed -i "s/^ *SRS_DOMAIN=.*/SRS_DOMAIN=$DOMAIN/" $CONFIGFILE.tmp
		mv -f $CONFIGFILE.tmp $CONFIGFILE
	fi

	# Create user
	if ! getent passwd postsrsd > /dev/null; then
		adduser --quiet --system --group --no-create-home --home /var/lib/postsrsd postsrsd

		# When upgrading from versions before 1.4, change the RUN_AS variable in the
		# configuration file from nobody to the postsrsd user.
		if dpkg --compare-versions "$2" lt "1.4-1"; then
			cp -a -f $CONFIGFILE $CONFIGFILE.tmp
			sed -i "s/^ *RUN_AS=nobody */RUN_AS=postsrsd/" $CONFIGFILE.tmp
			mv -f $CONFIGFILE.tmp $CONFIGFILE
		fi
	fi
fi

# Stop communcation with debconf, as the daemon might get confused with the extra file
# descriptor if we an init system that doesn't close it.
db_stop

#DEBHELPER#