From f7f3bef313d94439eae5a5763fb8b61ec0ad410f Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 10 Dec 2013 16:17:57 -0800 Subject: Move some stuff to clean up root. --- buildinstaller.sh | 4 +- ext/installfiles/linux/init.d/zerotier-one | 97 ++++++++++++++++++++++++++++++ ext/installfiles/linux/uninstall.sh | 41 +++++++++++++ ext/installfiles/mac/check_for_updates.sh | 2 + ext/installfiles/mac/uninstall.sh | 38 ++++++++++++ installer/linux/init.d/zerotier-one | 97 ------------------------------ installer/linux/uninstall.sh | 41 ------------- installer/mac/check_for_updates.sh | 2 - installer/mac/uninstall.sh | 38 ------------ 9 files changed, 180 insertions(+), 180 deletions(-) create mode 100755 ext/installfiles/linux/init.d/zerotier-one create mode 100755 ext/installfiles/linux/uninstall.sh create mode 100755 ext/installfiles/mac/check_for_updates.sh create mode 100755 ext/installfiles/mac/uninstall.sh delete mode 100755 installer/linux/init.d/zerotier-one delete mode 100755 installer/linux/uninstall.sh delete mode 100755 installer/mac/check_for_updates.sh delete mode 100755 installer/mac/uninstall.sh diff --git a/buildinstaller.sh b/buildinstaller.sh index 10eb66d5..4022bce7 100755 --- a/buildinstaller.sh +++ b/buildinstaller.sh @@ -53,8 +53,8 @@ case "$system" in echo "Assembling Linux installer for $machine and ZT1 version $vmajor.$vminor.$revision" - ./file2lz4c installer/linux/uninstall.sh uninstall_sh >installer-build/uninstall_sh.h - ./file2lz4c installer/linux/init.d/zerotier-one linux__init_d__zerotier_one >installer-build/linux__init_d__zerotier_one.h + ./file2lz4c ext/installfiles/linux/uninstall.sh uninstall_sh >installer-build/uninstall_sh.h + ./file2lz4c ext/installfiles/linux/init.d/zerotier-one linux__init_d__zerotier_one >installer-build/linux__init_d__zerotier_one.h g++ -Os -o "zt1-${vmajor}_${vminor}_${revision}-linux-${machine}-install" installer.cpp ext/lz4/lz4.o ext/lz4/lz4hc.o diff --git a/ext/installfiles/linux/init.d/zerotier-one b/ext/installfiles/linux/init.d/zerotier-one new file mode 100755 index 00000000..fdb8522a --- /dev/null +++ b/ext/installfiles/linux/init.d/zerotier-one @@ -0,0 +1,97 @@ +#!/bin/sh +# +# zerotier-one Virtual distributed Ethernet service +# +# chkconfig: 2345 11 89 +# description: ZeroTier One provides public and private distributed ethernet \ +# networks. See https://www.zerotier.com/ for more information. + +### BEGIN INIT INFO +# Provides: zerotier-one +# Required-Start: $local_fs $network +# Required-Stop: $local_fs +# Default-Start: 2345 +# Default-Stop: 90 +# Short-Description: start ZeroTier One +# Description: ZeroTier One provides public and private distributed ethernet \ +# networks. See https://www.zerotier.com/ for more information. +### END INIT INFO + +# +# 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. +# + +zthome=/var/lib/zerotier-one + +# 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 + +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 + rm -f "$zthome/zerotier-one.pid" + fi +fi + +case "$1" in + start) + if [ $running -gt 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) + if [ $running -gt 0 ]; then + echo "Stopping ZeroTier One..." + kill -TERM $pid + else + echo "ZeroTier One is not running." + fi + ;; + 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) + 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 0 diff --git a/ext/installfiles/linux/uninstall.sh b/ext/installfiles/linux/uninstall.sh new file mode 100755 index 00000000..18b8a50b --- /dev/null +++ b/ext/installfiles/linux/uninstall.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +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 $0" + exit 1 +fi + +echo + +echo "This will uninstall ZeroTier One, hit CTRL+C to abort." +echo "Waiting 5 seconds..." +sleep 5 + +echo "Killing any running zerotier-one service..." +killall -q -TERM zerotier-one +sleep 2 +killall -q -KILL zerotier-one + +echo "Removing SysV init items..." +rm -fv /etc/init.d/zerotier-one +find /etc/rc*.d -name '???zerotier-one' -print0 | xargs -0 rm -fv + +echo "Erasing binary and support files..." +cd /var/lib/zerotier-one +rm -fv zerotier-one *.persist authtoken.secret identity.public *.log *.pid +rm -rfv updates.d networks.d iddb.d + +echo "Erasing anything installed into system bin directories..." +rm -fv /usr/local/bin/zerotier-* /usr/bin/zerotier-* + +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 + +exit 0 diff --git a/ext/installfiles/mac/check_for_updates.sh b/ext/installfiles/mac/check_for_updates.sh new file mode 100755 index 00000000..05a7907c --- /dev/null +++ b/ext/installfiles/mac/check_for_updates.sh @@ -0,0 +1,2 @@ +#!/bin/bash + diff --git a/ext/installfiles/mac/uninstall.sh b/ext/installfiles/mac/uninstall.sh new file mode 100755 index 00000000..4fa26d00 --- /dev/null +++ b/ext/installfiles/mac/uninstall.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +export PATH=/bin:/usr/bin:/sbin:/usr/sbin + +if [ "$UID" -ne 0 ]; then + echo "Must be run as root; try: sudo $0" + exit 1 +fi + +echo + +echo "This will 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 >>/dev/null 2>&1 +sleep 3 +killall -KILL zerotier-one >>/dev/null 2>&1 + +echo "Unloading kernel extension..." +kextunload "$ztpath/tap.kext" + +echo "Erasing binary and support files..." +cd $ztpath +rm -rfv zerotier-one *.persist authtoken.secret identity.public *.log *.pid *.kext + +echo "Done." +echo +echo "Your ZeroTier One identity is still preserved in $ztpath" +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 + +exit 0 diff --git a/installer/linux/init.d/zerotier-one b/installer/linux/init.d/zerotier-one deleted file mode 100755 index fdb8522a..00000000 --- a/installer/linux/init.d/zerotier-one +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -# -# zerotier-one Virtual distributed Ethernet service -# -# chkconfig: 2345 11 89 -# description: ZeroTier One provides public and private distributed ethernet \ -# networks. See https://www.zerotier.com/ for more information. - -### BEGIN INIT INFO -# Provides: zerotier-one -# Required-Start: $local_fs $network -# Required-Stop: $local_fs -# Default-Start: 2345 -# Default-Stop: 90 -# Short-Description: start ZeroTier One -# Description: ZeroTier One provides public and private distributed ethernet \ -# networks. See https://www.zerotier.com/ for more information. -### END INIT INFO - -# -# 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. -# - -zthome=/var/lib/zerotier-one - -# 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 - -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 - rm -f "$zthome/zerotier-one.pid" - fi -fi - -case "$1" in - start) - if [ $running -gt 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) - if [ $running -gt 0 ]; then - echo "Stopping ZeroTier One..." - kill -TERM $pid - else - echo "ZeroTier One is not running." - fi - ;; - 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) - 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 0 diff --git a/installer/linux/uninstall.sh b/installer/linux/uninstall.sh deleted file mode 100755 index 18b8a50b..00000000 --- a/installer/linux/uninstall.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -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 $0" - exit 1 -fi - -echo - -echo "This will uninstall ZeroTier One, hit CTRL+C to abort." -echo "Waiting 5 seconds..." -sleep 5 - -echo "Killing any running zerotier-one service..." -killall -q -TERM zerotier-one -sleep 2 -killall -q -KILL zerotier-one - -echo "Removing SysV init items..." -rm -fv /etc/init.d/zerotier-one -find /etc/rc*.d -name '???zerotier-one' -print0 | xargs -0 rm -fv - -echo "Erasing binary and support files..." -cd /var/lib/zerotier-one -rm -fv zerotier-one *.persist authtoken.secret identity.public *.log *.pid -rm -rfv updates.d networks.d iddb.d - -echo "Erasing anything installed into system bin directories..." -rm -fv /usr/local/bin/zerotier-* /usr/bin/zerotier-* - -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 - -exit 0 diff --git a/installer/mac/check_for_updates.sh b/installer/mac/check_for_updates.sh deleted file mode 100755 index 05a7907c..00000000 --- a/installer/mac/check_for_updates.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash - diff --git a/installer/mac/uninstall.sh b/installer/mac/uninstall.sh deleted file mode 100755 index 4fa26d00..00000000 --- a/installer/mac/uninstall.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -export PATH=/bin:/usr/bin:/sbin:/usr/sbin - -if [ "$UID" -ne 0 ]; then - echo "Must be run as root; try: sudo $0" - exit 1 -fi - -echo - -echo "This will 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 >>/dev/null 2>&1 -sleep 3 -killall -KILL zerotier-one >>/dev/null 2>&1 - -echo "Unloading kernel extension..." -kextunload "$ztpath/tap.kext" - -echo "Erasing binary and support files..." -cd $ztpath -rm -rfv zerotier-one *.persist authtoken.secret identity.public *.log *.pid *.kext - -echo "Done." -echo -echo "Your ZeroTier One identity is still preserved in $ztpath" -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 - -exit 0 -- cgit v1.2.3