/[debian]/iodine/branches/NM/debian/iodine.iodined.init
ViewVC logotype

Contents of /iodine/branches/NM/debian/iodine.iodined.init

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1066 - (show annotations)
Mon Nov 26 20:08:05 2007 UTC (13 years, 9 months ago) by gregoa
File size: 3875 byte(s)
merge r1053:1065 from trunk
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: iodined
4 # Required-Start: $local_fs $network
5 # Required-Stop: $local_fs $network
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: initscript for iodined
9 # Description: initscript for iodined
10 ### END INIT INFO
11
12 # Author: gregor herrmann <gregor+debian@comodo.priv.at>
13
14 # Do NOT "set -e"
15
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"
19 NAME=iodined
20 DAEMON=/usr/sbin/$NAME
21 DEFAULT=iodine
22 DAEMON_ARGS=""
23 PIDFILE=/var/run/$NAME.pid
24 SCRIPTNAME=/etc/init.d/$NAME
25
26 # Exit if the package is not installed
27 [ -x "$DAEMON" ] || exit 0
28
29 # Read configuration variable file or exit
30 [ -r /etc/default/$DEFAULT ] || exit 0
31 . /etc/default/$DEFAULT
32
33 # Load the VERBOSE setting and other rcS variables
34 . /lib/init/vars.sh
35
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
39
40 # Get config
41 get_config() {
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."
44 exit 0
45 else
46 if [ -n "$IODINED_ARGS" ] && [ -n "$IODINED_PASSWORD" ] ; then
47 DAEMON_ARGS="-u iodine -t /var/run/iodine -P $IODINED_PASSWORD $IODINED_ARGS"
48 else
49 log_warning_msg "$NAME is not fully configured. Change this in /etc/default/$DEFAULT or run dpkg-reconfigure $DEFAULT."
50 exit 0
51 fi
52 fi
53 }
54
55 #
56 # Function that starts the daemon/service
57 #
58 do_start()
59 {
60 # populate $DAEMON_ARGS
61 get_config
62 # Return
63 # 0 if daemon has been started
64 # 1 if daemon was already running
65 # 2 if daemon could not be started
66 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
67 || return 1
68 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
69 $DAEMON_ARGS \
70 || return 2
71 # Add code here, if necessary, that waits for the process to be ready
72 # to handle requests from services started subsequently which depend
73 # on this one. As a last resort, sleep for some time.
74 }
75
76 #
77 # Function that stops the daemon/service
78 #
79 do_stop()
80 {
81 # Return
82 # 0 if daemon has been stopped
83 # 1 if daemon was already stopped
84 # 2 if daemon could not be stopped
85 # other if a failure occurred
86 start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --pidfile $PIDFILE --name $NAME
87 RETVAL="$?"
88 [ "$RETVAL" = 2 ] && return 2
89 # Wait for children to finish too if this is a daemon that forks
90 # and if the daemon is only ever run from this initscript.
91 # If the above conditions are not satisfied then add some other code
92 # that waits for the process to drop all resources that could be
93 # needed by services started subsequently. A last resort is to
94 # sleep for some time.
95 start-stop-daemon --stop --quiet --oknodo --retry=0/5/KILL/5 --exec $DAEMON
96 [ "$?" = 2 ] && return 2
97 # Many daemons don't delete their pidfiles when they exit.
98 rm -f $PIDFILE
99 return "$RETVAL"
100 }
101
102 case "$1" in
103 start)
104 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
105 do_start
106 case "$?" in
107 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
108 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
109 esac
110 ;;
111 stop)
112 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
113 do_stop
114 case "$?" in
115 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
116 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
117 esac
118 ;;
119 restart|force-reload)
120 log_daemon_msg "Restarting $DESC" "$NAME"
121 do_stop
122 case "$?" in
123 0|1)
124 do_start
125 case "$?" in
126 0) log_end_msg 0 ;;
127 1) log_end_msg 1 ;; # Old process is still running
128 *) log_end_msg 1 ;; # Failed to start
129 esac
130 ;;
131 *)
132 # Failed to stop
133 log_end_msg 1
134 ;;
135 esac
136 ;;
137 *)
138 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
139 exit 3
140 ;;
141 esac
142
143 :

  ViewVC Help
Powered by ViewVC 1.1.26