X-Git-Url: https://git.toastfreeware.priv.at/debian/iodine.git/blobdiff_plain/f1f2efad64627dbb2ec5697071770634130a49e5..eb26ade432143f1423f48345721c6f8f384de312:/debian/postinst?ds=sidebyside diff --git a/debian/postinst b/debian/postinst index 478d014..477a89e 100644 --- a/debian/postinst +++ b/debian/postinst @@ -3,8 +3,8 @@ # # see: dh_installdeb(1) +CONFIGFILE=/etc/default/iodine set -e - . /usr/share/debconf/confmodule # summary of how this script can be called: @@ -22,28 +22,55 @@ set -e case "$1" in configure) - # we need a tun device - if [ ! -e /dev/net/tun ] ; then - echo "Creating device /dev/net/tun ..." - cd /dev && WRITE_ON_UDEV=false ./MAKEDEV tun - fi - # and we want a special user - adduser --quiet --system --home /var/run/iodine iodine - # generate /etc/default/iodine - db_get iodine/start_daemon - START_IODINED=$RET - db_get iodine/daemon_options - IODINED_ARGS=$RET - db_get iodine/daemon_password - IODINED_PASSWORD=$RET - cat < /etc/default/iodine + # 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="$START_IODINED" -IODINED_ARGS="$IODINED_ARGS" -IODINED_PASSWORD="$IODINED_PASSWORD" +START_IODINED= +IODINED_ARGS= +IODINED_PASSWORD= EOF - [ -e /etc/default/iodine ] && chmod 600 /etc/default/iodine + 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) @@ -58,6 +85,14 @@ 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.