Last active
July 31, 2018 14:29
-
-
Save Nickel2Plus/60d90e61efd4ca30e3a368865438a8f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: vpnserver | |
# Required-Start: $local_fs $network | |
# Required-Stop: $local_fs $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: SoftEther VPN RTM | |
# Description: Start vpnserver daemon SoftEther VPN Server | |
### END INIT INFO | |
DAEMON=/usr/local/vpnserver/vpnserver | |
LOCK=/var/lock/vpnserver | |
# tun/tapモジュールのロード | |
sudo modprobe tun | |
. /lib/lsb/init-functions | |
test -x $DAEMON || exit 0 | |
case "$1" in | |
start) | |
sleep 3 | |
log_daemon_msg "Starting SoftEther VPN Server" "vpnserver" | |
$DAEMON start >/dev/null 2>&1 | |
touch $LOCK | |
log_end_msg 0 | |
sleep 3 | |
# SoftEther VPNで追加した仮想tapデバイス名を調べる | |
tap=`/sbin/ifconfig -a| awk '$1 ~ /^tap/ {print $1}'` | |
/sbin/brctl addif br0 $tap | |
;; | |
stop) | |
log_daemon_msg "Stopping SoftEther VPN Server" "vpnserver" | |
$DAEMON stop >/dev/null 2>&1 | |
rm $LOCK | |
log_end_msg 0 | |
sleep 2 | |
;; | |
restart) | |
$DAEMON stop | |
sleep 2 | |
$DAEMON start | |
sleep 5 | |
# SoftEther VPNで追加した仮想tapデバイス名を調べる | |
tap=`/sbin/ifconfig -a| awk '$1 ~ /^tap/ {print $1}'` | |
/sbin/brctl addif br0 $tap | |
;; | |
status) | |
if [ -e $LOCK ] | |
then | |
echo "vpnserver is running." | |
else | |
echo "vpnserver is not running." | |
fi | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment