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