slackbuilds_ponce/network/zerotier-one/rc.zerotier-one.new
Georgi kolev dc615fe3c5 network/zerotier-one: Added (ZeroTier One VPN).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
2024-05-16 13:45:47 +07:00

51 lines
1 KiB
Bash

#!/bin/sh
# Slackware init script for zerotier-one
# To change the default options, edit /etc/default/zerotier-one
if [ -r /etc/default/zerotier-one ]; then
. /etc/default/zerotier-one
fi
# Start zerotier-one
start_zerotier() {
if ! lsmod | grep -q "^tun " ; then
echo "Loading tun module..."
/sbin/modprobe tun
fi
if ! /usr/bin/pgrep --ns $$ --euid root -f "^/usr/sbin/zerotier-one" 1> /dev/null 2> /dev/null ; then
echo "Starting zerotier-one: /usr/sbin/zerotier-one $ZEROTIER_OPTS"
/usr/sbin/zerotier-one $ZEROTIER_OPTS &
echo $! > /var/run/zerotier-one.pid
fi
}
# Stop zerotier-one
stop_zerotier() {
echo "Stopping zerotier-one."
kill $(cat /var/run/zerotier-one.pid)
rm -f /var/run/zerotier-one.pid
}
# Restart zerotier-one
restart_zerotier() {
stop_zerotier
sleep 1
start_zerotier
}
# Parse command line parameters
case "$1" in
'start')
start_zerotier
;;
'stop')
stop_zerotier
;;
'restart')
restart_zerotier
;;
*)
echo "usage $0 start|stop|restart"
esac