wok view openvpn/stuff/etc/init.d/openvpn-server @ rev 19446
dillo: add stuff/fltk-1.3.3.u
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Oct 15 18:21:21 2016 +0200 (2016-10-15) |
parents | 7f188676b59c |
children |
line source
1 #!/bin/sh
2 # /etc/init.d/openvpn-server: Start, stop and restart openvpn daemon on SliTaz, at boot
3 # time or with the command line.
4 #
5 # To start daemon at boot time, just put the right name in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
7 #
8 . /etc/init.d/rc.functions
9 . /etc/daemons.conf
11 NAME=OpenVPN
12 DESC="$(_ '%s daemon' VPN)"
13 DAEMON=/usr/sbin/openvpn
14 OPTIONS=$OPENVPN_OPTIONS
15 PIDFILE=/var/run/openvpn-server.pid
17 checktundevice() {
18 if [ ! -e /dev/net/tun ]; then
19 if ! modprobe tun ; then
20 _ 'TUN/TAP support is not available in this Kernel'
21 return 1
22 fi
23 fi
24 if [ -h /dev/net/tun -a -c /dev/misc/net/tun ]; then
25 _ 'Detected broken %s symlink, fixing...' '/dev/net/tun'
26 rm -f /dev/net/tun
27 ln -s /dev/misc/net/tun /dev/net/tun
28 fi
29 }
31 [ -d /var/run/openvpn ] || mkdir -p /var/run/openvpn
33 case "$1" in
34 start)
35 checktundevice
37 if [ ! -e /etc/openvpn/server.conf ]; then
38 _ 'Missing OpenVPN server config.'
39 exit 1
40 fi
41 if active_pidfile $PIDFILE openvpn ; then
42 _ '%s is already running.' $NAME
43 exit 1
44 fi
45 action 'Starting %s: %s...' "$DESC" $NAME
46 $DAEMON $OPTIONS
47 status
48 ;;
49 stop)
50 if ! active_pidfile $PIDFILE openvpn ; then
51 _ '%s is not running.' $NAME
52 exit 1
53 fi
54 action 'Stopping %s: %s...' "$DESC" $NAME
55 kill $(cat $PIDFILE)
56 rm $PIDFILE
57 status
58 ;;
59 restart)
60 if ! active_pidfile $PIDFILE openvpn ; then
61 _ '%s is not running.' $NAME
62 exit 1
63 fi
64 action 'Restarting %s: %s...' "$DESC" $NAME
65 kill $(cat $PIDFILE)
66 rm $PIDFILE
67 sleep 2
68 $DAEMON $OPTIONS
69 status
70 ;;
71 *)
72 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]"
73 newline
74 exit 1
75 ;;
76 esac
78 exit 0