summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg2021-10-08 02:07:13 +0200
committerGeorg2021-10-08 02:07:13 +0200
commitf0317340170ecb313080c57f7ced473ec104050c (patch)
tree5a627272712a2fc63ea33276ec5feb84d7d2a647
parentc885a5ef8ae8ebccbbb9522c0eed08b64ec976c5 (diff)
downloadsystem-f0317340170ecb313080c57f7ced473ec104050c.tar.gz
system-f0317340170ecb313080c57f7ced473ec104050c.tar.bz2
system-f0317340170ecb313080c57f7ced473ec104050c.zip
NetBSD Tor update script + shell multiplexer
Signed-off-by: Georg <georg@lysergic.dev>
-rwxr-xr-xscripts/sh/multi.sh8
-rwxr-xr-xscripts/sh/update_tor_netbsd.sh66
2 files changed, 74 insertions, 0 deletions
diff --git a/scripts/sh/multi.sh b/scripts/sh/multi.sh
new file mode 100755
index 0000000..a42b85d
--- /dev/null
+++ b/scripts/sh/multi.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+#Simple wrapper for shmux
+#https://github.com/shmux/shmux
+
+HOSTS=`grep -w Host .ssh/config | sed -e 's/Host / /' - | sed -e 's/#.*//' - | tr -d '\n'`
+PAYLOAD="curl -s 202.61.255.170:9090/scripts/$1 | sh -"
+
+/usr/local/bin/shmux -C 5s -a lnregex -o /tmp/multi -r ssh -S all -T 10 -m -v -p -c "$PAYLOAD" $HOSTS
diff --git a/scripts/sh/update_tor_netbsd.sh b/scripts/sh/update_tor_netbsd.sh
new file mode 100755
index 0000000..77e7b47
--- /dev/null
+++ b/scripts/sh/update_tor_netbsd.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+# Easily update Tor routers on NetBSD to the source release version specified as VERSION
+# Combine this with multi.sh \o/
+
+set -eu
+
+if test `uname` = 'NetBSD'; then
+
+VERSION="0.4.6.7"
+TEMPDIR="~root/tmp"
+
+BINARY="/usr/local/bin/tor"
+check_version() {
+ $BINARY --version | sed 's/[^0-9.]*\([0-9.]*\).*/\1/' | head -n 1
+}
+
+if test `check_version` != "$VERSION."; then
+
+if ! test -d "$TEMPDIR"; then
+mkdir $TEMPDIR
+fi
+cd $TEMPDIR
+
+echo "Downloading ..."
+curl -sLO https://dist.torproject.org/tor-$VERSION.tar.gz
+
+echo "Extracting ..."
+tar -xzf tor-$VERSION.tar.gz
+
+echo "Configuring ..."
+cd tor-$VERSION
+./configure
+
+echo "Backing up ..."
+tar -czf /tmp/tor-`hostname -s`.tgz /etc/rc.d/tor /usr/local/etc/tor/torrc /var/chroot/tor
+
+echo "Stopping existing instances ..."
+set +e
+/etc/rc.d/tor stop
+sleep 2
+pkill -9 tor
+set -e
+
+echo "Removing shit ..."
+make uninstall
+
+echo "Compiling ..."
+# to-do
+#make -j `sysctl -n hw.ncpu`
+make
+
+echo "Installing ..."
+make install
+
+echo "Starting new instance ..."
+/etc/rc.d/tor start
+
+else
+ echo "Version matches, aborting."
+ exit 1
+fi
+
+else
+ echo "This script only supports NetBSD deployments."
+ exit 1
+fi