extend tor status

This commit is contained in:
rootzoll
2021-05-26 11:02:31 -05:00
parent 3d9e9b6442
commit 47a1407f11

View File

@@ -183,6 +183,11 @@ if [ -f "/mnt/hdd/raspiblitz.conf" ]; then
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
fi fi
torRunning=$(sudo systemctl --no-pager status tor@default | grep -c "Active: active")
torFunctional=$(curl --connect-timeout 30 --socks5-hostname "127.0.0.1:9050" https://check.torproject.org 2>/dev/null | grep -c "Congratulations. This browser is configured to use Tor.")
if [ "${torFunctional}" == "" ]; then torFunctional=0; fi
if [ ${torFunctional} -gt 1 ]; then torFunctional=1; fi
# if started with status # if started with status
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
# is Tor activated # is Tor activated
@@ -191,7 +196,8 @@ if [ "$1" = "status" ]; then
else else
echo "activated=0" echo "activated=0"
fi fi
echo "torRunning=${torRunning}"
echo "torFunctional=${torFunctional}"
echo "config='${torrc}'" echo "config='${torrc}'"
exit 0 exit 0
fi fi
@@ -258,21 +264,6 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^runBehindTor=.*/runBehindTor=on/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^runBehindTor=.*/runBehindTor=on/g" /mnt/hdd/raspiblitz.conf
# check if Tor was already installed and is funtional
echo ""
echo "# *** Check if Tor service is functional ***"
sudo systemctl --no-pager status tor@default
torRunningTest=$(sudo systemctl --no-pager status tor@default | grep -c "Active: active")
#torRunningTest=$(curl --connect-timeout 30 --socks5-hostname "127.0.0.1:9050" https://check.torproject.org 2>/dev/null | grep -c "Congratulations. This browser is configured to use Tor.")
if [ "${torRunningTest}" == "0" ]; then
echo "# Tor not running (${torRunningTest})... proceed with switching to Tor."
echo ""
else
echo "# You are all good - Tor is already running."
echo ""
exit 0
fi
# install package just in case it was deinstalled # install package just in case it was deinstalled
packageInstalled=$(dpkg -s tor-arm | grep -c 'Status: install ok') packageInstalled=$(dpkg -s tor-arm | grep -c 'Status: install ok')
if [ ${packageInstalled} -eq 0 ]; then if [ ${packageInstalled} -eq 0 ]; then