1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /root/magellan-cvs/src/openvpn/openvpn.rc,v 1.1 2007-09-28 16:05:44 niro Exp $ |
# $Header: /root/magellan-cvs/src/openvpn/openvpn.rc,v 1.2 2009-12-01 17:36:15 niro Exp $ |
3 |
|
|
4 |
#%rlevels: 3:s 4:s 5:s 0:k 1:k 2:k 6:k |
#%rlevels: 3:s 4:s 5:s 0:k 1:k 2:k 6:k |
5 |
#%start: 24 |
#%start: 24 |
10 |
#%before: |
#%before: |
11 |
#%after: |
#%after: |
12 |
|
|
13 |
source /etc/sysconfig/rc |
source /etc/conf.d/rc |
14 |
source $rc_functions |
source $rc_functions |
15 |
|
|
16 |
# Lockfile |
# Lockfile |
29 |
# load neccessary tun module |
# load neccessary tun module |
30 |
modprobe tun >/dev/null 2>&1 |
modprobe tun >/dev/null 2>&1 |
31 |
|
|
32 |
# Run startup script, if defined |
# run startup script, if defined |
33 |
if [ -x ${configdir}/opnvpn-startup ] |
if [ -x ${configdir}/opnvpn-startup ] |
34 |
then |
then |
35 |
echo " Running startup script ... " |
echo " Running startup script ... " |
40 |
|
|
41 |
rm -f ${piddir}/*.pid |
rm -f ${piddir}/*.pid |
42 |
|
|
43 |
# Start every .conf in /etc/openvpn and run .sh if exists |
# start every .conf in /etc/openvpn and run .sh if exists |
44 |
for config in ${configdir}/*.conf |
for config in ${configdir}/*.conf |
45 |
do |
do |
46 |
echo " Starting server for ${config} ... " |
echo " Starting server for ${config} ... " |
66 |
update_svcstatus $1 |
update_svcstatus $1 |
67 |
splash svc_started "$(basename $0)" 0 |
splash svc_started "$(basename $0)" 0 |
68 |
;; |
;; |
69 |
|
|
70 |
stop) |
stop) |
71 |
echo -e ${COLOREDSTAR}"Stopping OpenVPN:" |
echo -e ${COLOREDSTAR}"Stopping OpenVPN:" |
72 |
|
|
79 |
evaluate_retval |
evaluate_retval |
80 |
done |
done |
81 |
|
|
82 |
# Run shutdown script, if defined |
# run shutdown script, if defined |
83 |
if [[ -x ${configdir}/openvpn-shutdown ]] |
if [[ -x ${configdir}/openvpn-shutdown ]] |
84 |
then |
then |
85 |
echo " Running shutdown script ... " |
echo " Running shutdown script ... " |
90 |
update_svcstatus $1 |
update_svcstatus $1 |
91 |
splash svc_stopped "$(basename $0)" 0 |
splash svc_stopped "$(basename $0)" 0 |
92 |
;; |
;; |
93 |
|
|
94 |
restart) |
restart) |
95 |
$0 stop |
$0 stop |
96 |
sleep 2 |
sleep 2 |
97 |
$0 start |
$0 start |
98 |
;; |
;; |
99 |
|
|
100 |
reload) |
reload) |
101 |
for pidfile in ${piddir}/*.pid |
for pidfile in ${piddir}/*.pid |
102 |
do |
do |
107 |
evaluate_retval |
evaluate_retval |
108 |
done |
done |
109 |
;; |
;; |
110 |
|
|
111 |
reopen) |
reopen) |
112 |
for pidfile in ${piddir}/*.pid |
for pidfile in ${piddir}/*.pid |
113 |
do |
do |
118 |
evaluate_retval |
evaluate_retval |
119 |
done |
done |
120 |
;; |
;; |
121 |
|
|
122 |
status) |
status) |
123 |
statusproc /usr/sbin/openvpn |
statusproc /usr/sbin/openvpn |
124 |
;; |
;; |
125 |
|
|
126 |
*) |
*) |
127 |
echo "Usage: openvpn {start|stop|restart|reload|reopen|status}" |
echo "Usage: openvpn {start|stop|restart|reload|reopen|status}" |
128 |
exit 1 |
exit 1 |