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 /var/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 sed -e "s/^ *START_IODINED=.*/START_IODINED=\"$START_IODINED\"/" \
65 -e "s/^ *IODINED_ARGS=.*/IODINED_ARGS=\"$IODINED_ARGS\"/" \
66 -e "s/^ *IODINED_PASSWORD=.*/IODINED_PASSWORD=\"$IODINED_PASSWORD\"/" \
67 < $CONFIGFILE > $CONFIGFILE.tmp
69 mv -f $CONFIGFILE.tmp $CONFIGFILE
70 [ ! -e $CONFIGFILE ] || chmod 600 $CONFIGFILE
73 abort-upgrade|abort-remove|abort-deconfigure)
77 echo "postinst called with unknown argument \`$1'" >&2
82 # tell debconf we are done. otherwise, it hangs waiting for the daemon.
85 # dh_installdeb will replace this with shell code automatically
86 # generated by other debhelper scripts.