4 # Required-Start: $local_fs $network
5 # Required-Stop: $local_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
26 # Exit if the package is not installed
27 [ -x "$DAEMON" ] || exit 0
29 # Read configuration variable file or exit
30 [ -r /etc/default/$DEFAULT ] || exit 0
31 . /etc/default/$DEFAULT
33 # Load the VERBOSE setting and other rcS variables
36 # Define LSB log_* functions.
37 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
38 . /lib/lsb/init-functions
42 if [ "$START_IODINED" != "true" ] ; then
43 log_warning_msg "$NAME is not configured to start automatically. Change this in /etc/default/$DEFAULT or run dpkg-reconfigure $DEFAULT."
46 if [ -n "$IODINED_ARGS" ] && [ -n "$IODINED_PASSWORD" ] ; then
47 DAEMON_ARGS="-P $IODINED_PASSWORD $IODINED_ARGS"
49 log_warning_msg "$NAME is not fully configured. Change this in /etc/default/$DEFAULT or run dpkg-reconfigure $DEFAULT."
56 # Function that starts the daemon/service
61 # 0 if daemon has been started
62 # 1 if daemon was already running
63 # 2 if daemon could not be started
64 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
66 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
69 # Add code here, if necessary, that waits for the process to be ready
70 # to handle requests from services started subsequently which depend
71 # on this one. As a last resort, sleep for some time.
75 # Function that stops the daemon/service
80 # 0 if daemon has been stopped
81 # 1 if daemon was already stopped
82 # 2 if daemon could not be stopped
83 # other if a failure occurred
84 start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --pidfile $PIDFILE --name $NAME
86 [ "$RETVAL" = 2 ] && return 2
87 # Wait for children to finish too if this is a daemon that forks
88 # and if the daemon is only ever run from this initscript.
89 # If the above conditions are not satisfied then add some other code
90 # that waits for the process to drop all resources that could be
91 # needed by services started subsequently. A last resort is to
92 # sleep for some time.
93 start-stop-daemon --stop --quiet --oknodo --retry=0/5/KILL/5 --exec $DAEMON
94 [ "$?" = 2 ] && return 2
95 # Many daemons don't delete their pidfiles when they exit.
103 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
106 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
107 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
111 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
114 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
115 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
118 restart|force-reload)
119 log_daemon_msg "Restarting $DESC" "$NAME"
126 1) log_end_msg 1 ;; # Old process is still running
127 *) log_end_msg 1 ;; # Failed to start
137 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2