| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
CONFIGFILE=/etc/postsrsd.conf |
| 4 |
set -e |
| 5 |
. /usr/share/debconf/confmodule |
| 6 |
|
| 7 |
if [ "$1" = "configure" ]; then |
| 8 |
if [ ! -f /etc/postsrsd.secret ]; then |
| 9 |
echo "postsrsd: Generating initial /etc/postsrsd.secret" >&2 |
| 10 |
( umask 0077 ; dd if=/dev/urandom bs=24 count=1 2>/dev/null | base64 -w0 > /etc/postsrsd.secret ) |
| 11 |
fi |
| 12 |
|
| 13 |
# We'll only write the configured domain to the config file if it doesn't |
| 14 |
# exist yet, or we're called by dpkg-reconfigure. |
| 15 |
db_get postsrsd/domain; DOMAIN="$RET" |
| 16 |
|
| 17 |
if [ ! -e $CONFIGFILE ]; then |
| 18 |
cp -a -f /usr/share/postsrsd/postsrsd.template $CONFIGFILE.tmp |
| 19 |
# Replace empty domains with write configured domain to config file (but only if the domain is not empty). |
| 20 |
if [ ! -z "$DOMAIN" ]; then |
| 21 |
sed -i "s/^domains = {}/domains = { \"$DOMAIN\" }/" $CONFIGFILE.tmp |
| 22 |
fi |
| 23 |
mv -f $CONFIGFILE.tmp $CONFIGFILE |
| 24 |
fi |
| 25 |
|
| 26 |
if [ "$DEBCONF_RECONFIGURE" = "1" -a ! -z "$DOMAIN" ]; then |
| 27 |
cp -a -f $CONFIGFILE $CONFIGFILE.tmp |
| 28 |
sed -i "s/^domains = {.*/domains = { \"$DOMAIN\" }/" $CONFIGFILE.tmp |
| 29 |
mv -f $CONFIGFILE.tmp $CONFIGFILE |
| 30 |
fi |
| 31 |
|
| 32 |
# Create user |
| 33 |
if ! getent passwd postsrsd > /dev/null; then |
| 34 |
adduser --quiet --system --group --no-create-home --home /var/lib/postsrsd postsrsd |
| 35 |
fi |
| 36 |
fi |
| 37 |
|
| 38 |
# Stop communcation with debconf, as the daemon might get confused with the extra file |
| 39 |
# descriptor if we use an init system that doesn't close it. |
| 40 |
db_stop |
| 41 |
|
| 42 |
#DEBHELPER# |