]>
Commit | Line | Data |
---|---|---|
ebfe6087 SP |
1 | #!/bin/sh |
2 | # | |
3 | # accel-ppp accel-ppp service | |
4 | # | |
5 | # chkconfig: 345 90 15 | |
6 | # | |
7 | # description: accel-ppp (High performance VPN server application) | |
8 | # | |
9 | # processname: accel-pppd | |
10 | # config: /etc/accel-ppp.conf | |
11 | # pidfile: | |
12 | # | |
13 | # $Id: | |
14 | ||
15 | # Source function library | |
16 | . /etc/rc.d/init.d/functions | |
17 | ||
18 | # Get network config | |
19 | . /etc/sysconfig/network | |
20 | ||
21 | # Check that networking is up. | |
22 | if is_yes "${NETWORKING}"; then | |
23 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
24 | msg_network_down "accel-ppp" | |
25 | exit 1 | |
26 | fi | |
27 | else | |
28 | exit 0 | |
29 | fi | |
30 | ||
31 | # Set defaults | |
32 | OPTION1="" # Strings | |
33 | OPTION2="-q" # | |
34 | OPTION3= # Values | |
35 | OPTION4=5 # | |
36 | ||
37 | # Get service config - may override defaults | |
38 | [ -f /etc/sysconfig/accel-ppp ] && . /etc/sysconfig/accel-ppp | |
39 | ||
40 | pidfile="/var/run/accel-ppp.pid" | |
41 | ||
42 | # configtest itself | |
43 | # must return non-zero if check failed | |
44 | # output is discarded if checkconfig is ran without details | |
45 | configtest() { | |
46 | /usr/sbin/accel-pppd -t | |
47 | return $? | |
48 | } | |
49 | ||
50 | # wrapper for configtest | |
51 | checkconfig() { | |
52 | local details=${1:-0} | |
53 | ||
54 | if [ $details = 1 ]; then | |
55 | # run config test and display report (status action) | |
56 | show "Checking %s configuration" "accel-ppp"; busy | |
57 | local out | |
58 | out=$(configtest 2>&1) | |
59 | RETVAL=$? | |
60 | if [ $RETVAL = 0 ]; then | |
61 | ok | |
62 | else | |
63 | fail | |
64 | fi | |
65 | [ "$out" ] && echo >&2 "$out" | |
66 | else | |
67 | # run config test and abort with nice message if failed | |
68 | # (for actions checking status before action). | |
69 | configtest >/dev/null 2>&1 | |
70 | RETVAL=$? | |
71 | if [ $RETVAL != 0 ]; then | |
72 | show "Checking %s configuration" "accel-ppp"; fail | |
73 | nls 'Configuration test failed. See details with %s "checkconfig"' $0 | |
74 | exit $RETVAL | |
75 | fi | |
76 | fi | |
77 | } | |
78 | ||
79 | start() { | |
80 | # Check if the service is already running? | |
81 | if [ -f /var/lock/subsys/accel-ppp ]; then | |
82 | msg_already_running "accel-pppd" | |
83 | return | |
84 | fi | |
85 | ||
86 | checkconfig | |
87 | msg_starting "accel-pppd" | |
88 | daemon /usr/sbin/accel-pppd | |
89 | RETVAL=$? | |
90 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/accel-ppp | |
91 | } | |
92 | ||
93 | stop() { | |
94 | if [ ! -f /var/lock/subsys/accel-ppp ]; then | |
95 | msg_not_running "accel-pppd" | |
96 | return | |
97 | fi | |
98 | ||
99 | # Stop daemons. | |
100 | msg_stopping "accel-pppd" | |
101 | killproc accel-pppd | |
102 | killproc --pidfile $pidfile accel-pppd -TERM | |
103 | rm -f /var/lock/subsys/accel-ppp | |
104 | } | |
105 | ||
106 | reload() { | |
107 | if [ ! -f /var/lock/subsys/accel-ppp ]; then | |
108 | msg_not_running "accel-pppd" | |
109 | RETVAL=7 | |
110 | return | |
111 | fi | |
112 | ||
113 | checkconfig | |
114 | msg_reloading "accel-pppd" | |
115 | killproc accel-pppd -HUP | |
116 | killproc --pidfile $pidfile accel-pppd -HUP | |
117 | RETVAL=$? | |
118 | } | |
119 | ||
120 | condrestart() { | |
121 | if [ ! -f /var/lock/subsys/accel-ppp ]; then | |
122 | msg_not_running "accel-pppd" | |
123 | RETVAL=$1 | |
124 | return | |
125 | fi | |
126 | ||
127 | checkconfig | |
128 | stop | |
129 | start | |
130 | } | |
131 | ||
132 | RETVAL=0 | |
133 | # See how we were called. | |
134 | case "$1" in | |
135 | start) | |
136 | start | |
137 | ;; | |
138 | stop) | |
139 | stop | |
140 | ;; | |
141 | restart) | |
142 | checkconfig | |
143 | stop | |
144 | start | |
145 | ;; | |
146 | try-restart) | |
147 | condrestart 0 | |
148 | ;; | |
149 | # include force-reload here if program allows reloading without restart | |
150 | # otherwise remove reload action and support force-reload as restart if running | |
151 | reload|force-reload) | |
152 | reload | |
153 | ;; | |
154 | # use this one if program doesn't support reloading without restart | |
155 | force-reload) | |
156 | condrestart 7 | |
157 | ;; | |
158 | checkconfig|configtest) | |
159 | checkconfig 1 | |
160 | ;; | |
161 | status) | |
162 | status accel-ppp | |
ebfe6087 SP |
163 | RETVAL=$? |
164 | ;; | |
165 | *) | |
166 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}" | |
167 | exit 3 | |
168 | esac | |
169 | ||
170 | exit $RETVAL |