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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#!/bin/sh
# postinst script for iodine
#
# see: dh_installdeb(1)
CONFIGFILE=/etc/default/iodine
set -e
. /usr/share/debconf/confmodule
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
# we need a tun device
if [ ! -c /dev/net/tun ] && [ -x /dev/MAKEDEV ] ; then
echo "Creating device /dev/net/tun ..."
cd /dev
./MAKEDEV tun || true
fi
# and we want a special user
adduser --quiet --system --home /run/iodine iodine
# generate/update /etc/default/iodine
if [ ! -e $CONFIGFILE ]; then
cat <<EOF >$CONFIGFILE
# Default settings for iodine. This file is sourced from
# /etc/init.d/iodined
START_IODINED=
IODINED_ARGS=
IODINED_PASSWORD=
EOF
fi
db_get iodine/start_daemon
START_IODINED=$RET
db_get iodine/daemon_options
IODINED_ARGS=$RET
db_get iodine/daemon_password
IODINED_PASSWORD=$RET
cp -a -f $CONFIGFILE $CONFIGFILE.tmp
# If the admin deleted or commented some variables but then set
# them via debconf, (re-)add them to the conffile.
test -z "$START_IODINED" || grep -Eq '^ *START_IODINED=' $CONFIGFILE || \
echo "START_IODINED=" >> $CONFIGFILE
test -z "$IODINED_ARGS" || grep -Eq '^ *IODINED_ARGS=' $CONFIGFILE || \
echo "IODINED_ARGS=" >> $CONFIGFILE
test -z "$IODINED_PASSWORD" || grep -Eq '^ *IODINED_PASSWORD=' $CONFIGFILE || \
echo "IODINED_PASSWORD=" >> $CONFIGFILE
# PATTERN may contain variables, which will be interpolated every time the pattern search
# is evaluated, except for when the delimiter is a single quote.
# (perldoc perlop)
perl -p -e "s'^ *START_IODINED=.*'START_IODINED=\"$START_IODINED\"'; \
s'^ *IODINED_ARGS=.*'IODINED_ARGS=\"$IODINED_ARGS\"'; \
s'^ *IODINED_PASSWORD=.*'IODINED_PASSWORD=\"$IODINED_PASSWORD\"';" \
< $CONFIGFILE > $CONFIGFILE.tmp
mv -f $CONFIGFILE.tmp $CONFIGFILE
[ ! -e $CONFIGFILE ] || chmod 600 $CONFIGFILE
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# tell debconf we are done. otherwise, it hangs waiting for the daemon.
db_stop;
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
# mask iodined.service if START_IODINED is not set to true
# this mimicks the behaviour of sysvinit. cf. #832599
if [ "$1" = "configure" ] ; then
if [ "$START_IODINED" != "true" ] ; then
deb-systemd-helper mask iodined.service >/dev/null || true
fi
fi
exit 0
|