fix w/l interface status
[tomato.git] / release / src / router / xl2tpd / scripts / init.suse
blobc54635b786031aee8294fed0e5797beb580e991a
1 #! /bin/sh
2 # Copyright (c) 1995-2003
3 # Tronicplanet Datendienst GmbH, Simbach am INN, Germany.
4 # All rights reserved.
6 # Author: Bernhard Thoni <bt@tronicplanet.de>
8 # /etc/init.d/l2tpd
10 # and its symbolic link
12 # /(usr/)sbin/rcl2tpd
14 # LSB compliant service control script; see http://www.linuxbase.org/spec/
16 # System startup script for L2TP daemon l2tpd
18 ### BEGIN INIT INFO
19 # Provides: FOO
20 # Required-Start: $syslog
21 # Required-Stop: $syslog
22 # Default-Start: 3 5
23 # Default-Stop: 0 1 2 6
24 # Description: Start l2tpd to allow XY and provide YZ
25 # continued on second line by '#<TAB>'
26 ### END INIT INFO
28 # Note on Required-Start: It does specify the init script ordering,
29 # not real dependencies. Depencies have to be handled by admin
30 # resp. the configuration tools (s)he uses.
32 # Source SuSE config (if still necessary, most info has been moved)
33 test -r /etc/rc.config && . /etc/rc.config
35 # Check for missing binaries (stale symlinks should not happen)
36 L2TPD_BIN=/usr/sbin/l2tpd
37 test -x $L2TPD_BIN || exit 5
39 # Check for existence of needed config file and read it
40 #L2TPD_CONFIG=/etc/sysconfig/FOO
41 #test -r $L2TPD_CONFIG || exit 6
42 #. $L2TPD_CONFIG
44 # Shell functions sourced from /etc/rc.status:
45 # rc_check check and set local and overall rc status
46 # rc_status check and set local and overall rc status
47 # rc_status -v ditto but be verbose in local rc status
48 # rc_status -v -r ditto and clear the local rc status
49 # rc_failed set local and overall rc status to failed
50 # rc_failed <num> set local and overall rc status to <num><num>
51 # rc_reset clear local rc status (overall remains)
52 # rc_exit exit appropriate to overall rc status
53 # rc_active checks whether a service is activated by symlinks
54 . /etc/rc.status
56 # First reset status of this service
57 rc_reset
59 # Return values acc. to LSB for all commands but status:
60 # 0 - success
61 # 1 - generic or unspecified error
62 # 2 - invalid or excess argument(s)
63 # 3 - unimplemented feature (e.g. "reload")
64 # 4 - insufficient privilege
65 # 5 - program is not installed
66 # 6 - program is not configured
67 # 7 - program is not running
69 # Note that starting an already running service, stopping
70 # or restarting a not-running service as well as the restart
71 # with force-reload (in case signalling is not supported) are
72 # considered a success.
74 case "$1" in
75 start)
76 echo -n "Starting L2TPD"
77 ## Start daemon with startproc(8). If this fails
78 ## the echo return value is set appropriate.
80 # NOTE: startproc returns 0, even if service is
81 # already running to match LSB spec.
82 startproc $L2TPD_BIN >/dev/null 2>&1
84 # Remember status and be verbose
85 rc_status -v
87 stop)
88 echo -n "Shutting down L2TPD"
89 ## Stop daemon with killproc(8) and if this fails
90 ## set echo the echo return value.
92 killproc -TERM $L2TPD_BIN
94 # Remember status and be verbose
95 rc_status -v
97 try-restart)
98 ## Stop the service and if this succeeds (i.e. the
99 ## service was running before), start it again.
100 ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
101 $0 status >/dev/null && $0 restart
103 # Remember status and be quiet
104 rc_status
106 restart)
107 ## Stop the service and regardless of whether it was
108 ## running or not, start it again.
109 $0 stop
110 $0 start
112 # Remember status and be quiet
113 rc_status
115 force-reload)
116 ## Signal the daemon to reload its config. Most daemons
117 ## do this on signal 1 (SIGHUP).
118 ## If it does not support it, restart.
120 echo -n "Reload service L2TPD"
121 ## if it supports it:
122 killproc -HUP $L2TPD_BIN
123 #touch /var/run/l2tpd.pid
124 rc_status -v
126 ## Otherwise:
127 #$0 stop && $0 start
128 #rc_status
130 reload)
131 ## Like force-reload, but if daemon does not support
132 ## signalling, do nothing (!)
134 # If it supports signalling:
135 echo -n "Reload service L2TPD"
136 killproc -HUP $L2TPD_BIN
137 #touch /var/run/l2tpd.pid
138 rc_status -v
140 ## Otherwise if it does not support reload:
141 #rc_failed 3
142 #rc_status -v
144 status)
145 echo -n "Checking for service L2TPD: "
146 ## Check status with checkproc(8), if process is running
147 ## checkproc will return with exit status 0.
149 # Return value is slightly different for the status command:
150 # 0 - service running
151 # 1 - service dead, but /var/run/ pid file exists
152 # 2 - service dead, but /var/lock/ lock file exists
153 # 3 - service not running
155 # NOTE: checkproc returns LSB compliant status values.
156 checkproc $L2TPD_BIN
157 rc_status -v
159 probe)
160 ## Optional: Probe for the necessity of a reload,
161 ## print out the argument which is required for a reload.
163 test /etc/l2tpd/l2tpd.conf -nt /var/run/l2tpd.pid && echo reload
166 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
167 exit 1
169 esac
170 rc_exit