* Change mode of /etc/default/iodine to 600, thanks to Lennart Poettering
[debian/iodine.git] / debian / postinst
1 #!/bin/sh
2 # postinst script for iodine
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 . /usr/share/debconf/confmodule
9
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>
14 #          <new-version>
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
21
22
23 case "$1" in
24     configure)
25         # we need a tun device
26         if [ ! -e /dev/net/tun ] ; then
27                 echo "Creating device /dev/net/tun ..."
28                 cd /dev && WRITE_ON_UDEV=false ./MAKEDEV tun
29             fi
30             # and we want a special user
31             adduser --quiet --system --home /var/run/iodine iodine
32       # generate /etc/default/iodine
33       db_get iodine/start_daemon
34       START_IODINED=$RET
35       db_get iodine/daemon_options
36       IODINED_ARGS=$RET
37       db_get iodine/daemon_password
38       IODINED_PASSWORD=$RET
39       cat <<EOF > /etc/default/iodine
40 # Default settings for iodine. This file is sourced from
41 # /etc/init.d/iodined
42 START_IODINED="$START_IODINED"
43 IODINED_ARGS="$IODINED_ARGS"
44 IODINED_PASSWORD="$IODINED_PASSWORD"
45 EOF
46       [ -e /etc/default/iodine ] && chmod 600 /etc/default/iodine
47     ;;
48
49     abort-upgrade|abort-remove|abort-deconfigure)
50     ;;
51
52     *)
53         echo "postinst called with unknown argument \`$1'" >&2
54         exit 1
55     ;;
56 esac
57
58 # tell debconf we are done. otherwise, it hangs waiting for the daemon.
59 db_stop;
60
61 # dh_installdeb will replace this with shell code automatically
62 # generated by other debhelper scripts.
63
64 #DEBHELPER#
65
66 exit 0