mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-18 17:00:17 +00:00
Linux uninstall and init script.
This commit is contained in:
parent
34302edcc5
commit
085ad9073b
@ -17,99 +17,81 @@
|
||||
# networks. See https://www.zerotier.com/ for more information.
|
||||
### END INIT INFO
|
||||
|
||||
RETVAL=0
|
||||
prog="zerotier-one"
|
||||
exec="/var/lib/zerotier-one/zerotier-one"
|
||||
lockfile="/var/lock/subsys/zerotier-one"
|
||||
pidfile="/var/lib/zerotier-one/zerotier-one.pid"
|
||||
#
|
||||
# This script is written to avoid distro-specific dependencies, so it does not
|
||||
# use the rc bash script libraries found on some systems. It should work on
|
||||
# just about anything, even systems using Upstart. Upstart native support may
|
||||
# come in the future.
|
||||
#
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
zthome=/var/lib/zerotier-one
|
||||
|
||||
start() {
|
||||
if [ $UID -ne 0 ] ; then
|
||||
echo "User has insufficient privilege."
|
||||
exit 4
|
||||
fi
|
||||
[ -x $exec ] || exit 5
|
||||
echo -n $"Starting $prog: "
|
||||
daemon $exec
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
}
|
||||
# Add $zthome to path so we can invoke zerotier-one naked, makes it look
|
||||
# better in a ps listing.
|
||||
export PATH=/bin:/usr/bin:/sbin:/usr/sbin:$zthome
|
||||
|
||||
stop() {
|
||||
if [ $UID -ne 0 ] ; then
|
||||
echo "User has insufficient privilege."
|
||||
exit 4
|
||||
fi
|
||||
echo -n $"Stopping $prog: "
|
||||
pid=0
|
||||
if [ -f "$pidfile" ]; then
|
||||
pid=`cat $pidfile`
|
||||
fi
|
||||
if [ "$pid" -gt 0 ]; then
|
||||
kill -TERM $pid
|
||||
RETVAL=3
|
||||
if [ "$UID" -ne 0 ]; then
|
||||
echo "Init script must be called as root."
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [ ! -f "$zthome/zerotier-one" ]; then
|
||||
echo "ZeroTier One is not installed in $zthome."
|
||||
exit 5
|
||||
fi
|
||||
|
||||
pid=0
|
||||
if [ -f "$zthome/zerotier-one.pid" ]; then
|
||||
pid=`cat $zthome/zerotier-one.pid`
|
||||
fi
|
||||
|
||||
running=0
|
||||
if [ "$pid" -gt 0 ]; then
|
||||
if [ "`readlink -nf /proc/$pid/exe`" = "$zthome/zerotier-one" ]; then
|
||||
running=1
|
||||
else
|
||||
failure $"Stopping $prog"
|
||||
rm -f "$zthome/zerotier-one.pid"
|
||||
fi
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
status -p $pidfile $prog
|
||||
}
|
||||
|
||||
rh_status_q() {
|
||||
rh_status >/dev/null 2>&1
|
||||
}
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
if [ $running -eq 0 ]; then
|
||||
echo "ZeroTier One already running."
|
||||
exit 0
|
||||
fi
|
||||
echo "Starting ZeroTier One..."
|
||||
nohup zerotier-one >>/dev/null 2>&1 &
|
||||
disown %1
|
||||
exit 0
|
||||
;;
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
if [ $running -gt 0 ]; then
|
||||
echo "Stopping ZeroTier One..."
|
||||
kill -TERM $pid
|
||||
else
|
||||
echo "ZeroTier One is not running."
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
restart|reload|force-reload|condrestart|try-restart)
|
||||
echo "Restarting ZeroTier One..."
|
||||
if [ $running -gt 0 ]; then
|
||||
kill -TERM $pid
|
||||
fi
|
||||
while [ -f "$zthome/zerotier-one.pid" ]; do sleep 1; done
|
||||
nohup zerotier-one >>/dev/null 2>&1 &
|
||||
disown %1
|
||||
;;
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
if [ $running -gt 0 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||
exit 2
|
||||
esac
|
||||
exit $?
|
||||
|
||||
exit 0
|
||||
|
@ -3,32 +3,34 @@
|
||||
export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
|
||||
|
||||
if [ "$UID" -ne 0 ]; then
|
||||
echo "Must be run as root; try: sudo ./uninstall.sh"
|
||||
echo "Must be run as root; try: sudo $0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
echo "Going to uninstall zerotier-one, hit CTRL+C to abort."
|
||||
echo "Waiting 5 seconds..."
|
||||
sleep 5
|
||||
|
||||
ztpath="/Library/Application Support/ZeroTier/One"
|
||||
|
||||
echo "Killing any running zerotier-one service..."
|
||||
killall -TERM zerotier-one
|
||||
sleep 3
|
||||
killall -q -TERM zerotier-one
|
||||
sleep 2
|
||||
killall -q -KILL zerotier-one
|
||||
|
||||
echo "Erasing binary and support files..."
|
||||
cd $ztpath
|
||||
rm -fv zerotier-one
|
||||
rm -rfv updates.d
|
||||
rm -fv *.persist
|
||||
rm -rfv networks.d
|
||||
rm -fv authtoken.secret
|
||||
rm -fv identity.public
|
||||
cd /var/lib/zerotier-one
|
||||
rm -fv zerotier-one *.persist authtoken.secret identity.public *.log
|
||||
rm -rfv updates.d networks.d iddb.d
|
||||
|
||||
echo "Removing init items..."
|
||||
chkconfig zerotier-one off
|
||||
rm -fv /etc/init.d/zerotier-one
|
||||
find /etc/rc*.d -name '???zerotier-one' -print0 | xargs -0 rm -fv
|
||||
|
||||
echo "Done. (identity still preserved in $ztpath)"
|
||||
echo "Done."
|
||||
echo
|
||||
echo "Your ZeroTier One identity is still preserved in /var/lib/zerotier-one"
|
||||
echo "as identity.secret and can be manually deleted if you wish. Save it if"
|
||||
echo "you wish to re-use the address of this node, as it cannot be regenerated."
|
||||
|
||||
echo
|
||||
|
Loading…
x
Reference in New Issue
Block a user