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