#!/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: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # 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 <$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; # 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 # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0