mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-16 19:50:19 +01:00
dc615fe3c5
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
51 lines
1 KiB
Bash
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
|