wok-current annotate openvpn/stuff/etc/init.d/openvpn-client @ rev 23601
gst_plugins-base, gvfs-cdda: update deps
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Apr 11 08:38:42 2020 +0000 (2020-04-11) |
parents | 7f188676b59c |
children |
rev | line source |
---|---|
devl547@16412 | 1 #!/bin/sh |
al@19161 | 2 # /etc/init.d/openvpn-client: Start, stop and restart openvpn daemon 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 |
al@19159 | 12 DESC="$(_ '%s daemon' VPN)" |
devl547@16412 | 13 DAEMON=/usr/sbin/openvpn |
devl547@16412 | 14 OPTIONS=$OPENVPN_OPTIONS |
pascal@16681 | 15 PIDFILE=/var/run/openvpni-client.pid |
devl547@16412 | 16 |
devl547@16412 | 17 checktundevice() { |
devl547@16412 | 18 if [ ! -e /dev/net/tun ]; then |
devl547@16412 | 19 if ! modprobe tun ; then |
al@19159 | 20 _ 'TUN/TAP support is not available in this Kernel' |
devl547@16412 | 21 return 1 |
devl547@16412 | 22 fi |
devl547@16412 | 23 fi |
al@19159 | 24 if [ -h /dev/net/tun -a -c /dev/misc/net/tun ]; then |
al@19159 | 25 _ 'Detected broken %s symlink, fixing...' '/dev/net/tun' |
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 |
pascal@16681 | 31 [ -d /var/run/openvpn ] || mkdir -p /var/run/openvpn |
al@19159 | 32 |
devl547@16412 | 33 case "$1" in |
devl547@16412 | 34 start) |
devl547@16412 | 35 checktundevice |
devl547@16412 | 36 |
devl547@16412 | 37 if [ ! -e /etc/openvpn/client.conf ]; then |
al@19159 | 38 _ 'Missing OpenVPN client config.' |
devl547@16412 | 39 exit 1 |
devl547@16412 | 40 fi |
devl547@16412 | 41 if active_pidfile $PIDFILE openvpn ; then |
al@19159 | 42 _ '%s is already running.' $NAME |
devl547@16412 | 43 exit 1 |
devl547@16412 | 44 fi |
al@19159 | 45 action 'Starting %s: %s...' "$DESC" $NAME |
devl547@16412 | 46 $DAEMON --client $OPTIONS |
devl547@16412 | 47 status |
devl547@16412 | 48 ;; |
devl547@16412 | 49 stop) |
devl547@16412 | 50 if ! active_pidfile $PIDFILE openvpn ; then |
al@19159 | 51 _ '%s is not running.' $NAME |
devl547@16412 | 52 exit 1 |
devl547@16412 | 53 fi |
al@19159 | 54 action 'Stopping %s: %s...' "$DESC" $NAME |
al@19159 | 55 kill $(cat $PIDFILE) |
devl547@16412 | 56 rm $PIDFILE |
devl547@16412 | 57 status |
devl547@16412 | 58 ;; |
devl547@16412 | 59 restart) |
devl547@16412 | 60 if ! active_pidfile $PIDFILE openvpn ; then |
al@19159 | 61 _ '%s is not running.' $NAME |
devl547@16412 | 62 exit 1 |
devl547@16412 | 63 fi |
al@19159 | 64 action 'Restarting %s: %s...' "$DESC" $NAME |
al@19159 | 65 kill $(cat $PIDFILE) |
devl547@16412 | 66 rm $PIDFILE |
devl547@16412 | 67 sleep 2 |
devl547@16412 | 68 $DAEMON --client $OPTIONS |
devl547@16412 | 69 status |
devl547@16412 | 70 ;; |
devl547@16412 | 71 *) |
al@19159 | 72 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart]" |
al@19159 | 73 newline |
devl547@16412 | 74 exit 1 |
devl547@16412 | 75 ;; |
devl547@16412 | 76 esac |
devl547@16412 | 77 |
devl547@16412 | 78 exit 0 |