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

lxpanel,pcmanfm: stuff/autostart: update NotShowIn
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Sat Oct 10 19:39:47 2015 +0200 (2015-10-10)
parents cc6e05d2cb9a
children 7f188676b59c
line source
1 #!/bin/sh
2 # /etc/init.d/openvpn-client: Start, stop and restart openvpn 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/openvpni-client.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 [ -d /var/run/openvpn ] || mkdir -p /var/run/openvpn
32 case "$1" in
33 start)
34 checktundevice
36 if [ ! -e /etc/openvpn/client.conf ]; then
37 echo "Missing OpenVPN client config."
38 exit 1
39 fi
40 if active_pidfile $PIDFILE openvpn ; then
41 echo "$NAME already running."
42 exit 1
43 fi
44 echo -n "Starting $DESC: $NAME... "
45 $DAEMON --client $OPTIONS
46 status
47 ;;
48 stop)
49 if ! active_pidfile $PIDFILE openvpn ; then
50 echo "$NAME is not running."
51 exit 1
52 fi
53 echo -n "Stopping $DESC: $NAME... "
54 kill `cat $PIDFILE`
55 rm $PIDFILE
56 status
57 ;;
58 restart)
59 if ! active_pidfile $PIDFILE openvpn ; then
60 echo "$NAME is not running."
61 exit 1
62 fi
63 echo -n "Restarting $DESC: $NAME... "
64 kill `cat $PIDFILE`
65 rm $PIDFILE
66 sleep 2
67 $DAEMON --client $OPTIONS
68 status
69 ;;
70 *)
71 echo ""
72 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
73 echo ""
74 exit 1
75 ;;
76 esac
78 exit 0