Skip to content

Instantly share code, notes, and snippets.

@KMR-zoar
Created April 14, 2016 01:44
Show Gist options
  • Save KMR-zoar/aa51d33ae3e0ad503b5cd1a347e3c008 to your computer and use it in GitHub Desktop.
Save KMR-zoar/aa51d33ae3e0ad503b5cd1a347e3c008 to your computer and use it in GitHub Desktop.
#!/bin/sh
### BEGIN INIT INFO
# Provides: vpnup
# Required-Start: $all
# Required-Stop: $network $local_fs $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: SoftEther VPN Client
# chkconfig: 2345 99 1
# description: SoftEther VPN Client
### END INIT INFO
#
VPNCPATH="/usr/local/vpnclient/vpnclient"
VPNCUP=`pgrep vpnclient | wc -l`
VDEV="vpn_rpi3"
VPNinet="192.168.30.40/24"
#check vpnclient command.
test -x $VPNCPATH || exit 0
#echo $VPNCUP
#
case "$1" in
start)
if [ $VPNCUP = 0 ]; then
$VPNCPATH start
VNIC=`ip -4 -o addr | grep vpn_ | wc -l`
echo -n "waiting for startup virtualnic..."
while [ $VNIC = 0 ]
do
echo -n "."
sleep 1
VNIC=`ip -4 -o addr | grep vpn_ | wc -l`
done
ip a add $VPNinet dev $VDEV
echo "ok."
else
echo "VPN Client has started"
exit 1
fi
;;
stop)
if [ $VPNCUP = 0 ]; then
echo "VPN Client has stopped"
exit 1
else
$VPNCPATH stop
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment