From 5e8046f637b9d0cc57c36c70fa718fbc3f664f24 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 4 May 2018 15:32:18 +0100 Subject: [PATCH] Handle different tor health statuses --- src/freedombone-utils-onion | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/freedombone-utils-onion b/src/freedombone-utils-onion index 9c510ad4..7d9b47e9 100755 --- a/src/freedombone-utils-onion +++ b/src/freedombone-utils-onion @@ -324,7 +324,13 @@ function check_tor_health { echo 'fi'; echo 'if [ ! -f /tmp/.torfailed ]; then'; echo " tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME"; - echo ' touch /tmp/.torfailed'; + echo " echo \"\$status\" > /tmp/.torfailed"; + echo 'else'; + echo " prev_status=\$(cat /tmp/.torfailed)"; + echo " if [[ \"\$prev_status\" != \"\$status\" ]]; then"; + echo " tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME"; + echo " echo \"\$status\" > /tmp/.torfailed"; + echo ' fi'; echo 'fi'; } > /usr/bin/check_tor_health chmod +x /usr/bin/check_tor_health