wok-current annotate 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
rev   line source
devl547@16412 1 #!/bin/sh
devl547@16412 2 # /etc/init.d/rsyncd: Start, stop and restart Rsync deamon on SliTaz, at boot
devl547@16412 3 # time or with the command line.
devl547@16412 4 #
devl547@16412 5 # To start daemon at boot time, just put the right name in the $RUN_DAEMONS
devl547@16412 6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
devl547@16412 7 #
devl547@16412 8 . /etc/init.d/rc.functions
devl547@16412 9 . /etc/daemons.conf
devl547@16412 10
devl547@16412 11 NAME=OpenVPN
devl547@16412 12 DESC="VPN daemon"
devl547@16412 13 DAEMON=/usr/sbin/openvpn
devl547@16412 14 OPTIONS=$OPENVPN_OPTIONS
devl547@16412 15 PIDFILE=/var/run/rsyncd.pid
devl547@16412 16
devl547@16412 17 checktundevice() {
devl547@16412 18 if [ ! -e /dev/net/tun ]; then
devl547@16412 19 if ! modprobe tun ; then
devl547@16412 20 echo -n "TUN/TAP support is not available in this kernel"
devl547@16412 21 return 1
devl547@16412 22 fi
devl547@16412 23 fi
devl547@16412 24 if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then
devl547@16412 25 echo -n "Detected broken /dev/net/tun symlink, fixing..."
devl547@16412 26 rm -f /dev/net/tun
devl547@16412 27 ln -s /dev/misc/net/tun /dev/net/tun
devl547@16412 28 fi
devl547@16412 29 }
devl547@16412 30
devl547@16412 31 case "$1" in
devl547@16412 32 start)
devl547@16412 33 checktundevice
devl547@16412 34
devl547@16412 35 if [ ! -e /etc/openvpn/client.conf ]; then
devl547@16412 36 echo "Missing OpenVPN client config."
devl547@16412 37 exit 1
devl547@16412 38 fi
devl547@16412 39 if active_pidfile $PIDFILE openvpn ; then
devl547@16412 40 echo "$NAME already running."
devl547@16412 41 exit 1
devl547@16412 42 fi
devl547@16412 43 echo -n "Starting $DESC: $NAME... "
devl547@16412 44 $DAEMON --client $OPTIONS
devl547@16412 45 status
devl547@16412 46 ;;
devl547@16412 47 stop)
devl547@16412 48 if ! active_pidfile $PIDFILE openvpn ; then
devl547@16412 49 echo "$NAME is not running."
devl547@16412 50 exit 1
devl547@16412 51 fi
devl547@16412 52 echo -n "Stopping $DESC: $NAME... "
devl547@16412 53 kill `cat $PIDFILE`
devl547@16412 54 rm $PIDFILE
devl547@16412 55 status
devl547@16412 56 ;;
devl547@16412 57 restart)
devl547@16412 58 if ! active_pidfile $PIDFILE openvpn ; then
devl547@16412 59 echo "$NAME is not running."
devl547@16412 60 exit 1
devl547@16412 61 fi
devl547@16412 62 echo -n "Restarting $DESC: $NAME... "
devl547@16412 63 kill `cat $PIDFILE`
devl547@16412 64 rm $PIDFILE
devl547@16412 65 sleep 2
devl547@16412 66 $DAEMON --client $OPTIONS
devl547@16412 67 status
devl547@16412 68 ;;
devl547@16412 69 *)
devl547@16412 70 echo ""
devl547@16412 71 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
devl547@16412 72 echo ""
devl547@16412 73 exit 1
devl547@16412 74 ;;
devl547@16412 75 esac
devl547@16412 76
devl547@16412 77 exit 0