4 # Required-Start: $remote_fs $network
5 # Required-Stop: $remote_fs $network
6 # Default-Start: 2 3 4 5
8 # Short-Description: initscript for iodined
9 # Description: initscript for iodined
12 # Author: gregor herrmann <gregor+debian@comodo.priv.at>
16 # PATH should only include /usr/* if it runs after the mountnfs.sh script
17 PATH=/sbin:/usr/sbin:/bin:/usr/bin
18 DESC="IP over DNS tunneling server"
20 DAEMON=/usr/sbin/$NAME
23 PIDFILE=/var/run/$NAME.pid
24 SCRIPTNAME=/etc/init.d/$NAME
25 CHROOTDIR=/var/run/iodine
27 # Exit if the package is not installed
28 [ -x "$DAEMON" ] || exit 0
30 # Read configuration variable file or exit
31 [ -r /etc/default/$DEFAULT ] || exit 0
32 . /etc/default/$DEFAULT
34 # Load the VERBOSE setting and other rcS variables
37 # Define LSB log_* functions.
38 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
39 . /lib/lsb/init-functions
43 if [ "$START_IODINED" != "true" ] ; then
44 [ "$VERBOSE" != no ] && log_progress_msg "- automatic start disabled" && log_end_msg 0
47 if [ -n "$IODINED_ARGS" ] && [ -n "$IODINED_PASSWORD" ] ; then
48 DAEMON_ARGS="-u iodine -t $CHROOTDIR -P $IODINED_PASSWORD $IODINED_ARGS"
50 [ "$VERBOSE" != no ] && log_warning_msg "$NAME is not fully configured. Change this in /etc/default/$DEFAULT or run dpkg-reconfigure $DEFAULT."
58 if [ -d "$CHROOTDIR" ] || mkdir -p "$CHROOTDIR" ; then
61 [ "$VERBOSE" != no ] && log_failure_msg "$CHROOTDIR does not exist and can't be created."
67 # Function that starts the daemon/service
71 # populate $DAEMON_ARGS
77 # 0 if daemon has been started
78 # 1 if daemon was already running
79 # 2 if daemon could not be started
80 start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
82 start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS \
84 # Add code here, if necessary, that waits for the process to be ready
85 # to handle requests from services started subsequently which depend
86 # on this one. As a last resort, sleep for some time.
90 # Function that stops the daemon/service
95 # 0 if daemon has been stopped
96 # 1 if daemon was already stopped
97 # 2 if daemon could not be stopped
98 # other if a failure occurred
99 start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --exec $DAEMON
101 [ "$RETVAL" = 2 ] && return 2
102 # Wait for children to finish too if this is a daemon that forks
103 # and if the daemon is only ever run from this initscript.
104 # If the above conditions are not satisfied then add some other code
105 # that waits for the process to drop all resources that could be
106 # needed by services started subsequently. A last resort is to
107 # sleep for some time.
108 start-stop-daemon --stop --quiet --oknodo --retry=0/5/KILL/5 --exec $DAEMON
109 [ "$?" = 2 ] && return 2
110 # Many daemons don't delete their pidfiles when they exit.
117 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
120 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
121 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
125 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
128 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
129 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
132 restart|force-reload)
133 log_daemon_msg "Restarting $DESC" "$NAME"
140 1) log_end_msg 1 ;; # Old process is still running
141 *) log_end_msg 1 ;; # Failed to start
151 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2