wok view openvpn/stuff/etc/init.d/openvpn-client @ rev 16412

Up: openvpn (2.3.3), added openvpn-doc, added initscript (TEST AND FIX, PLEASE)
author Alexander Medvedev <devl547@gmail.com>
date Thu Apr 17 14:01:12 2014 +0400 (2014-04-17)
parents
children 0d8a1a3edc72
line source
1 #!/bin/sh
2 # /etc/init.d/rsyncd: Start, stop and restart Rsync deamon 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="VPN daemon"
13 DAEMON=/usr/sbin/openvpn
14 OPTIONS=$OPENVPN_OPTIONS
15 PIDFILE=/var/run/rsyncd.pid
17 checktundevice() {
18 if [ ! -e /dev/net/tun ]; then
19 if ! modprobe tun ; then
20 echo -n "TUN/TAP support is not available in this kernel"
21 return 1
22 fi
23 fi
24 if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then
25 echo -n "Detected broken /dev/net/tun symlink, fixing..."
26 rm -f /dev/net/tun
27 ln -s /dev/misc/net/tun /dev/net/tun
28 fi
29 }
31 case "$1" in
32 start)
33 checktundevice
35 if [ ! -e /etc/openvpn/client.conf ]; then
36 echo "Missing OpenVPN client config."
37 exit 1
38 fi
39 if active_pidfile $PIDFILE openvpn ; then
40 echo "$NAME already running."
41 exit 1
42 fi
43 echo -n "Starting $DESC: $NAME... "
44 $DAEMON --client $OPTIONS
45 status
46 ;;
47 stop)
48 if ! active_pidfile $PIDFILE openvpn ; then
49 echo "$NAME is not running."
50 exit 1
51 fi
52 echo -n "Stopping $DESC: $NAME... "
53 kill `cat $PIDFILE`
54 rm $PIDFILE
55 status
56 ;;
57 restart)
58 if ! active_pidfile $PIDFILE openvpn ; then
59 echo "$NAME is not running."
60 exit 1
61 fi
62 echo -n "Restarting $DESC: $NAME... "
63 kill `cat $PIDFILE`
64 rm $PIDFILE
65 sleep 2
66 $DAEMON --client $OPTIONS
67 status
68 ;;
69 *)
70 echo ""
71 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
72 echo ""
73 exit 1
74 ;;
75 esac
77 exit 0