2013-11-06 20:04:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
|
|
|
|
|
|
|
|
if [ "$UID" -ne 0 ]; then
|
2013-11-08 19:32:23 +00:00
|
|
|
echo "Must be run as root; try: sudo $0"
|
2013-11-06 20:04:05 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-02-14 23:18:59 +00:00
|
|
|
# Detect systemd vs. regular init
|
|
|
|
SYSTEMDUNITDIR=
|
|
|
|
if [ -e /bin/systemctl -o -e /usr/bin/systemctl -o -e /usr/local/bin/systemctl -o -e /sbin/systemctl -o -e /usr/sbin/systemctl ]; then
|
|
|
|
if [ -e /usr/bin/pkg-config ]; then
|
|
|
|
SYSTEMDUNITDIR=`/usr/bin/pkg-config systemd --variable=systemdsystemunitdir`
|
|
|
|
fi
|
|
|
|
if [ -z "$SYSTEMDUNITDIR" -o ! -d "$SYSTEMDUNITDIR" ]; then
|
|
|
|
if [ -d /usr/lib/systemd/system ]; then
|
|
|
|
SYSTEMDUNITDIR=/usr/lib/systemd/system
|
|
|
|
fi
|
|
|
|
if [ -d /etc/systemd/system ]; then
|
|
|
|
SYSTEMDUNITDIR=/etc/systemd/system
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-11-08 19:32:23 +00:00
|
|
|
echo
|
|
|
|
|
2013-11-08 22:37:47 +00:00
|
|
|
echo "This will uninstall ZeroTier One, hit CTRL+C to abort."
|
2013-11-06 20:04:05 +00:00
|
|
|
echo "Waiting 5 seconds..."
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
echo "Killing any running zerotier-one service..."
|
2014-02-14 23:18:59 +00:00
|
|
|
if [ -n "$SYSTEMDUNITDIR" -a -d "$SYSTEMDUNITDIR" ]; then
|
|
|
|
systemctl stop zerotier-one
|
|
|
|
systemctl disable zerotier-one
|
|
|
|
else
|
2014-03-05 21:33:58 +00:00
|
|
|
if [ -f /sbin/service -o -f /usr/sbin/service -o -f /bin/service -o -f /usr/bin/service ]; then
|
|
|
|
service stop zerotier-one
|
|
|
|
fi
|
2014-02-14 23:18:59 +00:00
|
|
|
fi
|
|
|
|
sleep 1
|
2013-11-08 19:32:23 +00:00
|
|
|
killall -q -TERM zerotier-one
|
2014-02-14 23:18:59 +00:00
|
|
|
sleep 1
|
2013-11-06 20:04:05 +00:00
|
|
|
killall -q -KILL zerotier-one
|
|
|
|
|
2014-02-14 23:18:59 +00:00
|
|
|
if [ -f /etc/init.d/zerotier-one ]; then
|
|
|
|
echo "Removing SysV init items..."
|
2014-03-05 21:33:58 +00:00
|
|
|
if [ -f /sbin/chkconfig -o -f /usr/sbin/chkconfig -o -f /bin/chkconfig -o -f /usr/bin/chkconfig ]; then
|
|
|
|
chkconfig zerotier-one off
|
|
|
|
fi
|
2014-02-14 23:18:59 +00:00
|
|
|
rm -f /etc/init.d/zerotier-one
|
2014-03-05 21:33:58 +00:00
|
|
|
find /etc/rc*.d -type f -name '???zerotier-one' -print0 | xargs -0 rm -f
|
2014-02-14 23:18:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$SYSTEMDUNITDIR" -a -d "$SYSTEMDUNITDIR" -a -f "$SYSTEMDUNITDIR/zerotier-one.service" ]; then
|
|
|
|
echo "Removing systemd service..."
|
|
|
|
rm -f "$SYSTEMDUNITDIR/zerotier-one.service"
|
|
|
|
fi
|
2013-11-08 22:37:47 +00:00
|
|
|
|
2013-11-06 20:04:05 +00:00
|
|
|
echo "Erasing binary and support files..."
|
2014-02-14 23:18:59 +00:00
|
|
|
if [ -d /var/lib/zerotier-one ]; then
|
|
|
|
cd /var/lib/zerotier-one
|
|
|
|
rm -rf zerotier-one *.persist identity.public *.log *.pid *.sh updates.d networks.d iddb.d
|
|
|
|
fi
|
2013-11-06 20:04:05 +00:00
|
|
|
|
2013-11-08 22:37:47 +00:00
|
|
|
echo "Erasing anything installed into system bin directories..."
|
2014-02-14 23:18:59 +00:00
|
|
|
rm -f /usr/local/bin/zerotier-cli /usr/bin/zerotier-cli
|
2013-11-08 19:32:23 +00:00
|
|
|
|
|
|
|
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."
|
2013-11-06 20:04:05 +00:00
|
|
|
|
2013-11-08 19:32:23 +00:00
|
|
|
echo
|
2013-11-13 14:07:59 +00:00
|
|
|
|
|
|
|
exit 0
|