#!/bin/bash <<ENDOFSIGSTART= -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
ENDOFSIGSTART=
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin # # ZeroTier install script # # All this script does is determine your OS and/or distribution and then add the correct # repository or download the correct package and install it. It then starts the service # and prints your device's ZeroTier address. # # Base URL for download.zerotier.com tree; see https://github.com/zerotier/download.zerotier.com if you want to mirror. # Some things want http, some https, so we must specify both. Must include trailing / ZT_BASE_URL_HTTPS='https://download.zerotier.com/' ZT_BASE_URL_HTTP='http://download.zerotier.com/'
echo echo '*** ZeroTier Service Quick Install for Unix-like Systems' echo echo '*** Tested OSes / distributions:' echo echo '*** MacOS (10.13+) (just installs ZeroTier One.pkg)' echo '*** Debian Linux (7+)' echo '*** RedHat/CentOS Linux (6+)' echo '*** Fedora Linux (16+)' echo '*** SuSE Linux (12+)' echo '*** Mint Linux (18+)' echo echo '*** Supported architectures vary by OS / distribution. We try to support' echo '*** every system architecture supported by the target.' echo echo '*** Please report problems to [email protected] and we will try to fix.' echo
SUDO= if [ "$UID" != "0" ]; then if [ -e /usr/bin/sudo -o -e /bin/sudo ]; then SUDO=sudo else echo '*** This quick installer script requires root privileges.' exit 0 fi fi # Detect MacOS and install .pkg file there if [ -e /usr/bin/uname ]; then if [ "`/usr/bin/uname -s`" = "Darwin" ]; then echo '*** Detected MacOS / Darwin, downloading and installing Mac .pkg...' $SUDO rm -f "/tmp/ZeroTier One.pkg" curl -s ${ZT_BASE_URL_HTTPS}dist/ZeroTier%20One.pkg >"/tmp/ZeroTier One.pkg" $SUDO installer -pkg "/tmp/ZeroTier One.pkg" -target /
echo echo '*** Waiting for identity generation...'
while [ ! -f "/Library/Application Support/ZeroTier/One/identity.secret" ]; do sleep 1 done
echo echo "*** Success! You are connected to port `cat '/Library/Application Support/ZeroTier/One/identity.public' | cut -d : -f 1` of Earth's planetary smart switch." echo
exit 0 fi fi # Detect already-installed on Linux if [ -f /usr/sbin/zerotier-one ]; then echo '*** ZeroTier appears to already be installed.' exit 0 fi
if [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F -i LinuxMint`" ]; then # Linux Mint -> Ubuntu 'xenial' echo '*** Found Linux Mint, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/xenial xenial main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F trusty`" ]; then # Ubuntu 'trusty' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/trusty trusty main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F wily`" ]; then # Ubuntu 'wily' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/wily wily main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F xenial`" ]; then # Ubuntu 'xenial' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/xenial xenial main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F zesty`" ]; then # Ubuntu 'zesty' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/zesty zesty main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F precise`" ]; then # Ubuntu 'precise' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/precise precise main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F artful`" ]; then # Ubuntu 'artful' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/artful artful main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F bionic`" ]; then # Ubuntu 'bionic' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/bionic bionic main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F yakkety`" ]; then # Ubuntu 'yakkety' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/yakkety yakkety main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F disco`" ]; then # Ubuntu 'disco' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/disco disco main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F focal`" ]; then # Ubuntu 'focal' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/focal focal main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F hirsute`" ]; then # Ubuntu 'hirsute' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/bionic bionic main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a -n "`cat /etc/lsb-release 2>/dev/null | grep -F impish`" ]; then # Ubuntu 'impish' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/bionic bionic main" >/tmp/zt-sources-list elif [ -f /etc/lsb-release -a '(' -n "`cat /etc/lsb-release 2>/dev/null | grep -F jammy`" -o -n "`cat /etc/lsb-release 2>/dev/null | grep -F kinetic`" ')' ]; then # Ubuntu 'jammy' or 'kinetic' echo '*** Found Ubuntu, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/jammy jammy main" >/tmp/zt-sources-list elif [ "$dvers" = "6" -o "$dvers" = "squeeze" ]; then # Debian 'squeeze' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/squeeze squeeze main" >/tmp/zt-sources-list elif [ "$dvers" = "7" -o "$dvers" = "wheezy" ]; then # Debian 'wheezy' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/wheezy wheezy main" >/tmp/zt-sources-list elif [ "$dvers" = "8" -o "$dvers" = "jessie" ]; then # Debian 'jessie' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/jessie jessie main" >/tmp/zt-sources-list elif [ "$dvers" = "9" -o "$dvers" = "stretch" ]; then # Debian 'stretch' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/stretch stretch main" >/tmp/zt-sources-list elif [ "$dvers" = "10" -o "$dvers" = "buster" -o "$dvers" = "parrot" ]; then # Debian 'buster' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/buster buster main" >/tmp/zt-sources-list elif [ "$dvers" = "11" -o "$dvers" = "bullseye" ]; then # Debian 'bullseye' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/bullseye bullseye main" >/tmp/zt-sources-list elif [ "$dvers" = "12" -o "$dvers" = "bookworm" ]; then # Debian 'bookworm' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/bookworm bookworm main" >/tmp/zt-sources-list elif [ "$dvers" = "testing" -o "$dvers" = "sid" ]; then # Debian 'testing', 'sid', and 'bookworm' -> Debian 'bookworm' echo '*** Found Debian, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/bookworm bookworm main" >/tmp/zt-sources-list else # Use Debian "buster" for unrecognized Debians echo '*** Found Debian or Debian derivative, creating /etc/apt/sources.list.d/zerotier.list' echo "deb ${ZT_BASE_URL_HTTP}debian/buster buster main" >/tmp/zt-sources-list fi $SUDO apt-get update -y $SUDO apt-get install -y gpg $SUDO mv -f /tmp/zt-sources-list /etc/apt/sources.list.d/zerotier.list $SUDO chown 0 /etc/apt/sources.list.d/zerotier.list $SUDO chgrp 0 /etc/apt/sources.list.d/zerotier.list $SUDO chmod a+r /tmp/zt-gpg-key if [ -d /etc/apt/trusted.gpg.d ]; then $SUDO gpg --dearmor < /tmp/zt-gpg-key > /etc/apt/trusted.gpg.d/zerotier-debian-package-key.gpg else $SUDO apt-key add /tmp/zt-gpg-key fi $SUDO rm -f /tmp/zt-gpg-key
echo echo '*** Installing zerotier-one package...' # Pre-1.1.6 Debian package did not properly enumerate its files, causing # problems when we try to replace it. So just delete them to force. if [ -d /var/lib/zerotier-one ]; then $SUDO rm -f /etc/init.d/zerotier-one /etc/systemd/system/multi-user.target.wants/zerotier-one.service /var/lib/zerotier-one/zerotier-one /usr/local/bin/zerotier-cli /usr/bin/zerotier-cli /usr/local/bin/zero fi
echo echo '*** Installing ZeroTier service package...'
if [ -e /usr/bin/dnf ]; then cat /dev/null | $SUDO dnf install -y zerotier-one else cat /dev/null | $SUDO yum install -y zerotier-one fi fi $SUDO rm -f /tmp/zt-gpg-key
if [ ! -e /usr/sbin/zerotier-one ]; then echo echo '*** Package installation failed! Unfortunately there may not be a package' echo '*** for your architecture or distribution. For the source go to:' echo '*** https://github.com/zerotier/ZeroTierOne' echo exit 1 fi
echo echo '*** Enabling and starting ZeroTier service...'
if [ -e /usr/bin/systemctl -o -e /usr/sbin/systemctl -o -e /sbin/systemctl -o -e /bin/systemctl ]; then $SUDO systemctl enable zerotier-one $SUDO systemctl start zerotier-one if [ "$?" != "0" ]; then echo echo '*** Package installed but cannot start service! You may be in a Docker' echo '*** container or using a non-standard init service.' echo exit 1 fi else if [ -e /sbin/update-rc.d -o -e /usr/sbin/update-rc.d -o -e /bin/update-rc.d -o -e /usr/bin/update-rc.d ]; then $SUDO update-rc.d zerotier-one defaults else $SUDO chkconfig zerotier-one on fi $SUDO /etc/init.d/zerotier-one start fi
echo echo '*** Waiting for identity generation...'
while [ ! -f /var/lib/zerotier-one/identity.secret ]; do sleep 1 done
echo echo "*** Success! You are ZeroTier address [ `cat /var/lib/zerotier-one/identity.public | cut -d : -f 1` ]." echo
Aug 24 18:02:57 packer-tool1024 systemd: ztncui.service holdoff time over, scheduling restart. Aug 24 18:02:57 packer-tool1024 systemd: Stopped ztncui - ZeroTier network controller user interface. Aug 24 18:02:57 packer-tool1024 systemd: Started ztncui - ZeroTier network controller user interface. Aug 24 18:02:58 packer-tool1024 ztncui: pkg/prelude/bootstrap.js:1876 Aug 24 18:02:58 packer-tool1024 ztncui: throw error; Aug 24 18:02:58 packer-tool1024 ztncui: ^ Aug 24 18:02:58 packer-tool1024 ztncui: Error: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /opt/key-networks/ztncui/node_modules/argon2/build/Release/argon2.node) Aug 24 18:02:58 packer-tool1024 ztncui: at process.dlopen (pkg/prelude/bootstrap.js:2255:28) Aug 24 18:02:58 packer-tool1024 ztncui: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18) Aug 24 18:02:58 packer-tool1024 ztncui: at Module.load (node:internal/modules/cjs/loader:981:32) Aug 24 18:02:58 packer-tool1024 ztncui: at Function.Module._load (node:internal/modules/cjs/loader:822:12) Aug 24 18:02:58 packer-tool1024 ztncui: at Module.require (node:internal/modules/cjs/loader:1005:19) Aug 24 18:02:58 packer-tool1024 ztncui: at Module.require (pkg/prelude/bootstrap.js:1855:31) Aug 24 18:02:58 packer-tool1024 ztncui: at require (node:internal/modules/cjs/helpers:102:18) Aug 24 18:02:58 packer-tool1024 ztncui: at bindings (/snapshot/src/node_modules/bindings/bindings.js:112:48) Aug 24 18:02:58 packer-tool1024 ztncui: at Object.<anonymous> (/snapshot/src/node_modules/argon2/argon2.js:3:37) Aug 24 18:02:58 packer-tool1024 ztncui: at Module._compile (pkg/prelude/bootstrap.js:1930:22) { Aug 24 18:02:58 packer-tool1024 ztncui: code: 'ERR_DLOPEN_FAILED' Aug 24 18:02:58 packer-tool1024 ztncui: } Aug 24 18:02:58 packer-tool1024 systemd: ztncui.service: main process exited, code=exited, status=1/FAILURE Aug 24 18:02:58 packer-tool1024 systemd: Unit ztncui.service entered failed state. Aug 24 18:02:58 packer-tool1024 systemd: ztncui.service failed. Aug 24 18:02:58 packer-tool1024 systemd: ztncui.service holdoff time over, scheduling restart. Aug 24 18:02:58 packer-tool1024 systemd: Stopped ztncui - ZeroTier network controller user interface. Aug 24 18:02:58 packer-tool1024 systemd: start request repeated too quickly for ztncui.service Aug 24 18:02:58 packer-tool1024 systemd: Failed to start ztncui - ZeroTier network controller user interface. Aug 24 18:02:58 packer-tool1024 systemd: Unit ztncui.service entered failed state. Aug 24 18:02:58 packer-tool1024 systemd: ztncui.service failed.
# systemctl status ztncui ● ztncui.service - ztncui - ZeroTier network controller user interface Loaded: loaded (/usr/lib/systemd/system/ztncui.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2023-08-25 09:59:23 CST; 3s ago Docs: https://key-networks.com Main PID: 6138 (ztncui) CGroup: /system.slice/ztncui.service └─6138 /opt/key-networks/ztncui/ztncui Aug 25 09:59:23 lavm-8wb0f24x4j systemd[1]: Started ztncui - ZeroTier network controller user interface. Aug 25 09:59:24 lavm-8wb0f24x4j ztncui[6138]: Warning: connect.session() MemoryStore is not Aug 25 09:59:24 lavm-8wb0f24x4j ztncui[6138]: designed for a production environment, as it will leak Aug 25 09:59:24 lavm-8wb0f24x4j ztncui[6138]: memory, and will not scale past a single process. Aug 25 09:59:24 lavm-8wb0f24x4j ztncui[6138]: Listening for HTTP requests on port 3000 on localhost Aug 25 09:59:24 lavm-8wb0f24x4j ztncui[6138]: Listening for HTTPS requests on port 3443 on all interfaces