Skip to content

Instantly share code, notes, and snippets.

@whoamiTM
Last active October 9, 2018 15:24
Show Gist options
  • Save whoamiTM/b16748cdee2cd3430cfd02c909db1736 to your computer and use it in GitHub Desktop.
Save whoamiTM/b16748cdee2cd3430cfd02c909db1736 to your computer and use it in GitHub Desktop.
SoftEther Client init & Auto Routing Config | ChromeOS | etc/init.d/vpnclient
#! /bin/sh
#######################################################
### SoftEther Client
#######################################################
### BEGIN INIT INFO
# Provides: vpnclient
# Required-Start: $all
# Required-Stop: $network $local_fs $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VPN Client at boot time
# chkconfig: 345 44 56
# description: Start VPN Client at boot time.
# processname: vpnclient
# 55.55.55.55 = VPN public IP
### END INIT INFO
# /etc/init.d/vpnclient
###########################
case "$1" in
start)
echo "Starting VPN Client"
/usr/local/vpnclient/vpnclient start
sleep 1
if ifconfig -a | grep vpn_vpn >/dev/null
then
echo "Setting up vpn_vpn..."
else
echo "Interface vpn_vpn not found" &1>2
ifdown vpn_vpn
sleep 1
ifup vpn_vpn
sleep 1
echo "Setting up vpn_vpn..."
exit 1
fi
route add -host 55.55.55.55 gw $(ip route list exact 0.0.0.0/0 | grep wlan0 | xargs | awk '{print $3}')
# route del default
# route add default gw 192.168.30.1 dev vpn_vpn
/usr/local/vpnclient/./vpncmd
;;
stop)
echo "Stopping VPN Client"
/usr/local/vpnclient/vpnclient stop
route del -host 55.55.55.55
#route del default
route add default gw $(ip route list exact 0.0.0.0/0 | grep wlan0 | xargs | awk '{print $3}') dev wlan0
;;
*)
echo "Usage: /etc/init.d/vpnclient {start|stop}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment