2 # postinst script for iodine
4 # see: dh_installdeb(1)
6 CONFIGFILE=/etc/default/iodine
8 . /usr/share/debconf/confmodule
10 # summary of how this script can be called:
11 # * <postinst> `configure' <most-recently-configured-version>
12 # * <old-postinst> `abort-upgrade' <new version>
13 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
15 # * <postinst> `abort-remove'
16 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
17 # <failed-install-package> <version> `removing'
18 # <conflicting-package> <version>
19 # for details, see http://www.debian.org/doc/debian-policy/ or
20 # the debian-policy package
25 # we need a tun device
26 if [ ! -c /dev/net/tun ] && [ -x /dev/MAKEDEV ] ; then
27 echo "Creating device /dev/net/tun ..."
32 # and we want a special user
33 adduser --quiet --system --home /run/iodine iodine
35 # generate/update /etc/default/iodine
36 if [ ! -e $CONFIGFILE ]; then
37 cat <<EOF >$CONFIGFILE
38 # Default settings for iodine. This file is sourced from
46 db_get iodine/start_daemon
48 db_get iodine/daemon_options
50 db_get iodine/daemon_password
53 cp -a -f $CONFIGFILE $CONFIGFILE.tmp
55 # If the admin deleted or commented some variables but then set
56 # them via debconf, (re-)add them to the conffile.
57 test -z "$START_IODINED" || grep -Eq '^ *START_IODINED=' $CONFIGFILE || \
58 echo "START_IODINED=" >> $CONFIGFILE
59 test -z "$IODINED_ARGS" || grep -Eq '^ *IODINED_ARGS=' $CONFIGFILE || \
60 echo "IODINED_ARGS=" >> $CONFIGFILE
61 test -z "$IODINED_PASSWORD" || grep -Eq '^ *IODINED_PASSWORD=' $CONFIGFILE || \
62 echo "IODINED_PASSWORD=" >> $CONFIGFILE
64 # PATTERN may contain variables, which will be interpolated every time the pattern search
65 # is evaluated, except for when the delimiter is a single quote.
67 perl -p -e "s'^ *START_IODINED=.*'START_IODINED=\"$START_IODINED\"'; \
68 s'^ *IODINED_ARGS=.*'IODINED_ARGS=\"$IODINED_ARGS\"'; \
69 s'^ *IODINED_PASSWORD=.*'IODINED_PASSWORD=\"$IODINED_PASSWORD\"';" \
70 < $CONFIGFILE > $CONFIGFILE.tmp
72 mv -f $CONFIGFILE.tmp $CONFIGFILE
73 [ ! -e $CONFIGFILE ] || chmod 600 $CONFIGFILE
76 abort-upgrade|abort-remove|abort-deconfigure)
80 echo "postinst called with unknown argument \`$1'" >&2
85 # tell debconf we are done. otherwise, it hangs waiting for the daemon.
88 # dh_installdeb will replace this with shell code automatically
89 # generated by other debhelper scripts.
93 # mask iodined.service if START_IODINED is not set to true
94 # this mimicks the behaviour of sysvinit. cf. #832599
95 if [ "$1" = "configure" ] ; then
96 if [ "$START_IODINED" != "true" ] ; then
97 deb-systemd-helper mask iodined.service >/dev/null || true