summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg2021-10-08 02:50:52 +0200
committerGeorg2021-10-08 02:50:52 +0200
commit01566df11df5eddfbdb14f34eaef3a6f2ada7222 (patch)
tree5f67bf3917ebe14b9041e89b4c20719c788035fe
parentf0317340170ecb313080c57f7ced473ec104050c (diff)
downloadsystem-01566df11df5eddfbdb14f34eaef3a6f2ada7222.tar.gz
system-01566df11df5eddfbdb14f34eaef3a6f2ada7222.tar.bz2
system-01566df11df5eddfbdb14f34eaef3a6f2ada7222.zip
Universal Tor check script
Signed-off-by: Georg <georg@lysergic.dev>
-rwxr-xr-xscripts/sh/check_tor.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/sh/check_tor.sh b/scripts/sh/check_tor.sh
new file mode 100755
index 0000000..216c3a4
--- /dev/null
+++ b/scripts/sh/check_tor.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# Query tor node
+# Designed to be run with multi.sh
+
+version_check() {
+ if [ -f "$PKGBINARY" ]; then
+ echo "Packaged version:"
+ $PKGBINARY --version
+ else
+ echo "No packaged version."
+ fi
+ if [ -f "$SRCBINARY" ]; then
+ echo "Source version:"
+ $SRCBINARY --version
+ else
+ echo "No source version."
+ fi
+
+}
+
+run_check_linux() {
+ # to-do: check if Sytemd or SysV-Init and behave accordingly
+ systemctl is-active tor
+}
+
+run_check_bsd() {
+ if [ -f "$RCSCRIPT" ]; then
+ $RCSCRIPT status
+ else
+ ps aux |grep tor
+ fi
+}
+
+echo "Found in PATH: `command -v tor`"
+
+case `uname` in
+ 'Linux' )
+ PKGBINARY="/usr/bin/tor"
+ SRCBINARY="/usr/local/bin/tor"
+ version_check
+ run_check_linux
+ ;;
+ 'NetBSD' )
+ PKGBINARY="/usr/pkg/bin/tor"
+ SRCBINARY="/usr/local/bin/tor"
+ RCSCRIPT="/etc/rc.d/tor"
+ version_check
+ run_check_bsd
+ ;;
+esac