]>
Commit | Line | Data |
---|---|---|
b68a277b JK |
1 | #!/bin/sh |
2 | # | |
3 | # openl2tpd Start/Stop the OpenL2TP protocol daemon. | |
4 | # | |
5 | # chkconfig: 2345 57 76 | |
6 | # description: OpenL2TP is a complete implementation of RFC2661 - Layer Two Tunneling | |
7 | # Protocol Version 2, able to operate as both a server and a client. It | |
8 | # can be used to implement L2TP VPNs. As a server, it can handle | |
9 | # hundreds of tunnels and sessions. | |
10 | # processname: openl2tpd | |
11 | # config: /etc/sysconfig/openl2tpd | |
12 | # pidfile: /var/run/openl2tpd.pid | |
13 | ||
14 | # Source function library. | |
15 | . /etc/init.d/functions | |
16 | ||
17 | OPENL2TPDARGS="" | |
18 | OPENL2TPD_CONFIG_FILE="" | |
19 | ||
20 | [ -f /etc/sysconfig/openl2tpd ] && . /etc/sysconfig/openl2tpd | |
21 | ||
22 | start() { | |
23 | # Check if the service is already running? | |
24 | if [ -f /var/lock/subsys/openl2tpd ]; then | |
25 | msg_already_running "openl2tpd" | |
26 | return | |
27 | fi | |
28 | ||
29 | msg_starting "openl2tpd" | |
30 | emit starting JOB=openl2tpd | |
31 | ||
32 | modprobe -s pppol2tp || modprobe -s l2tp_ppp | |
33 | RETVAL=$? | |
34 | if [ $RETVAL -eq 0 ]; then | |
35 | daemon openl2tpd $OPENL2TPDARGS | |
36 | RETVAL=$? | |
37 | fi | |
38 | if [ $RETVAL -eq 0 ]; then | |
39 | touch /var/lock/subsys/openl2tpd | |
40 | emit started JOB=openl2tpd | |
41 | if [ -n "$OPENL2TPD_CONFIG_FILE" -a -f "$OPENL2TPD_CONFIG_FILE" ]; then | |
42 | sleep 1 | |
43 | show "Restoring saved openl2tpd configuration..." ; busy | |
44 | /usr/bin/l2tpconfig config restore file="$OPENL2TPD_CONFIG_FILE" | |
45 | RETVAL=$? | |
46 | if [ $RETVAL -eq 0 ] ; then | |
47 | ok | |
48 | else | |
49 | fail | |
50 | fi | |
51 | fi | |
52 | fi | |
53 | } | |
54 | ||
55 | stop() { | |
56 | if [ ! -f /var/lock/subsys/openl2tpd ]; then | |
57 | msg_not_running "openl2tpd" | |
58 | return | |
59 | fi | |
60 | msg_stopping "openl2tpd" | |
61 | killproc openl2tpd | |
62 | emit --no-wait stopped JOB=openl2tpd | |
63 | rm -f /var/run/openl2tpd.pid /var/lock/subsys/openl2tpd >/dev/null 2>&1 | |
64 | return 0 | |
65 | } | |
66 | ||
67 | condrestart() { | |
68 | if [ ! -f /var/lock/subsys/openl2tpd ]; then | |
69 | msg_not_running "openl2tpd" | |
70 | RETVAL=$1 | |
71 | return | |
72 | fi | |
73 | ||
74 | stop | |
75 | start | |
76 | } | |
77 | ||
78 | restart() { | |
79 | stop | |
80 | start | |
81 | } | |
82 | ||
83 | reload() { | |
84 | if [ ! -f /var/lock/subsys/openl2tpd ]; then | |
85 | msg_not_running "openl2tpd" | |
86 | RETVAL=7 | |
87 | return | |
88 | fi | |
89 | ||
90 | if [ -n "$OPENL2TPD_CONFIG_FILE" -a -f "$OPENL2TPD_CONFIG_FILE" ]; then | |
91 | msg_reloading "openl2tpd" | |
92 | /usr/bin/l2tpconfig config restore file="$OPENL2TPD_CONFIG_FILE" | |
93 | RETVAL=$? | |
94 | if [ $RETVAL -eq 0 ] ; then | |
95 | ok | |
96 | else | |
97 | fail | |
98 | fi | |
99 | else | |
100 | stop | |
101 | start | |
102 | fi | |
103 | } | |
104 | ||
105 | RETVAL=0 | |
106 | # See how we were called. | |
107 | case "$1" in | |
108 | start) | |
109 | start | |
110 | ;; | |
111 | stop) | |
112 | stop | |
113 | ;; | |
114 | restart) | |
115 | restart | |
116 | ;; | |
117 | try-restart) | |
118 | condrestart 0 | |
119 | ;; | |
120 | reload|force-reload) | |
121 | reload | |
122 | ;; | |
123 | status) | |
124 | status openl2tpd | |
125 | RETVAL=$? | |
126 | l2tpconfig system show status | |
127 | ;; | |
128 | condrestart) | |
129 | condrestart | |
130 | ;; | |
131 | *) | |
132 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" | |
133 | exit 3 | |
134 | esac | |
135 | ||
136 | exit $RETVAL | |
137 |