postinst: change order.
[debian/iodine.git] / debian / postinst
index 61d5fdd6e822fd563582bdb9b64cd452a7a77bc6..477a89edecc868cc77e51451f45003a25b78b65d 100644 (file)
@@ -27,10 +27,10 @@ case "$1" in
             echo "Creating device /dev/net/tun ..."
             cd /dev
             ./MAKEDEV tun || true
             echo "Creating device /dev/net/tun ..."
             cd /dev
             ./MAKEDEV tun || true
-        fi 
+        fi
 
         # and we want a special user
 
         # and we want a special user
-        adduser --quiet --system --home /var/run/iodine iodine
+        adduser --quiet --system --home /run/iodine iodine
 
         # generate/update /etc/default/iodine
         if [ ! -e $CONFIGFILE ]; then
 
         # generate/update /etc/default/iodine
         if [ ! -e $CONFIGFILE ]; then
@@ -61,9 +61,12 @@ EOF
         test -z "$IODINED_PASSWORD" || grep -Eq '^ *IODINED_PASSWORD=' $CONFIGFILE || \
             echo "IODINED_PASSWORD=" >> $CONFIGFILE
 
         test -z "$IODINED_PASSWORD" || grep -Eq '^ *IODINED_PASSWORD=' $CONFIGFILE || \
             echo "IODINED_PASSWORD=" >> $CONFIGFILE
 
-        perl -p -e "s{^ *START_IODINED=.*}{START_IODINED=\"$START_IODINED\"}; \
-                    s{^ *IODINED_ARGS=.*}{IODINED_ARGS=\"$IODINED_ARGS\"}; \
-                    s{^ *IODINED_PASSWORD=.*}{IODINED_PASSWORD=\"$IODINED_PASSWORD\"};" \
+        # 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
             < $CONFIGFILE > $CONFIGFILE.tmp
 
         mv -f $CONFIGFILE.tmp $CONFIGFILE
@@ -82,6 +85,14 @@ esac
 # tell debconf we are done. otherwise, it hangs waiting for the daemon.
 db_stop;
 
 # 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.
 
 # dh_installdeb will replace this with shell code automatically
 # generated by other debhelper scripts.