Allow IPv6 address entry in tools>ping - Loosens valid character check
[tomato/davidwu.git] / release / src / router / xl2tpd / packaging / suse / xl2tpd.init
blob46aa0d8f2ae9d753200a197c2e561757779f8f10
1 #! /bin/sh
2 # Copyright (c) 1995-2003 Bernhard Thoni <bt@tronicplanet.de>
3 # Tronicplanet Datendienst GmbH, Simbach am INN, Germany.
4 # All rights reserved.
5 # Copyright (c) 2006-2008 Paul Wouters <paul@xelerance.com>
6 # Xeleracne Corporation
8 # /etc/init.d/xl2tpd
10 # and its symbolic link
12 # /usr/sbin/rcxl2tpd
14 # LSB compliant service control script; see http://www.linuxbase.org/spec/
16 # System startup script for L2TP daemon xl2tpd
18 ### BEGIN INIT INFO
19 # Provides: xl2tpd
20 # Required-Start: $syslog
21 # Required-Stop: $syslog
22 # Default-Start: 3 5
23 # Default-Stop: 0 1 2 6
24 # Short-Description: Start xl2tpd (to provide L2TP VPN's)
25 # Description: Start xl2tpd to provide L2TP VPN tunnels
26 # normally used with IPsec (openswan)
27 ### END INIT INFO
29 # Note on Required-Start: It does specify the init script ordering,
30 # not real dependencies. Depencies have to be handled by admin
31 # resp. the configuration tools (s)he uses.
33 # Source SuSE config (if still necessary, most info has been moved)
34 test -r /etc/rc.config && . /etc/rc.config
36 # Check for missing binaries (stale symlinks should not happen)
37 XL2TPD_BIN=/usr/sbin/xl2tpd
38 test -x $YPBIND_BIN || { echo "$YPBIND_BIN not installed";
39 if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; }
41 # Check for existence of needed config file and read it
42 #XL2TPD_CONFIG=/etc/sysconfig/xl2tpd
43 #test -r $YPBIND_CONFIG || { echo "$YPBIND_CONFIG not existing";
44 # if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; }
45 #. $XL2TPD_CONFIG
47 # Shell functions sourced from /etc/rc.status:
48 # rc_check check and set local and overall rc status
49 # rc_status check and set local and overall rc status
50 # rc_status -v ditto but be verbose in local rc status
51 # rc_status -v -r ditto and clear the local rc status
52 # rc_failed set local and overall rc status to failed
53 # rc_failed <num> set local and overall rc status to <num><num>
54 # rc_reset clear local rc status (overall remains)
55 # rc_exit exit appropriate to overall rc status
56 # rc_active checks whether a service is activated by symlinks
57 . /etc/rc.status
59 # First reset status of this service
60 rc_reset
62 # Return values acc. to LSB for all commands but status:
63 # 0 - success
64 # 1 - generic or unspecified error
65 # 2 - invalid or excess argument(s)
66 # 3 - unimplemented feature (e.g. "reload")
67 # 4 - insufficient privilege
68 # 5 - program is not installed
69 # 6 - program is not configured
70 # 7 - program is not running
72 # Note that starting an already running service, stopping
73 # or restarting a not-running service as well as the restart
74 # with force-reload (in case signalling is not supported) are
75 # considered a success.
77 case "$1" in
78 start)
79 echo -n "Starting xl2tpd"
80 ## Start daemon with startproc(8). If this fails
81 ## the echo return value is set appropriate.
83 # NOTE: startproc returns 0, even if service is
84 # already running to match LSB spec.
85 startproc $XL2TPD_BIN >/dev/null 2>&1
87 # Remember status and be verbose
88 rc_status -v
90 stop)
91 echo -n "Shutting down xl2tpd"
92 ## Stop daemon with killproc(8) and if this fails
93 ## set echo the echo return value.
95 killproc -TERM $XL2TPD_BIN
96 rm -f /var/run/xl2tpd/xl2tpd.pid
97 # Remember status and be verbose
98 rc_status -v
100 try-restart|condrestart)
101 ## Do a restart only if the service was active before.
102 ## Note: try-restart is now part of LSB (as of 1.9).
103 ## RH has a similar command named condrestart.
104 if test "$1" = "condrestart"; then
105 echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
107 $0 status
108 if test $? = 0; then
109 $0 restart
110 else
111 rc_reset # Not running is not a failure.
113 rc_status
115 restart)
116 $0 stop
117 sleep 1
118 $0 start
119 rc_status
121 force-reload)
122 ## Signal the daemon to reload its config. Most daemons
123 ## do this on signal 1 (SIGHUP).
124 ## If it does not support it, restart.
125 echo -n "Reload service xl2tpd"
126 ## if it supports it:
127 killproc -HUP $XL2TPD_BIN
128 #touch /var/run/xl2tpd/xl2tpd.pid
129 rc_status -v
130 ## Otherwise:
131 #$0 stop && $0 start
132 #rc_status
134 reload)
135 ## Like force-reload, but if daemon does not support
136 ## signalling, do nothing (!)
137 # If it supports signalling:
138 echo -n "Reload service xl2tpd"
139 killproc -HUP $XL2TPD_BIN
140 #touch /var/run/xl2tpd.pid
141 rc_status -v
142 ## Otherwise if it does not support reload:
143 #rc_failed 3
144 #rc_status -v
146 status)
147 echo -n "Checking for service xl2tpd: "
148 ## Check status with checkproc(8), if process is running
149 ## checkproc will return with exit status 0.
151 # Return value is slightly different for the status command:
152 # 0 - service running
153 # 1 - service dead, but /var/run/ pid file exists
154 # 2 - service dead, but /var/lock/ lock file exists
155 # 3 - service not running
157 # NOTE: checkproc returns LSB compliant status values.
158 checkproc $XL2TPD_BIN
159 rc_status -v
161 probe)
162 ## Optional: Probe for the necessity of a reload,
163 ## print out the argument which is required for a reload.
165 test /etc/xl2tpd/xl2tpd.conf -nt /var/run/xltpd/xl2tpd.pid && echo reload
168 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
169 exit 1
171 esac
172 rc_exit