From 59af1821b94e7d883d44685cb04178c7fbf96c92 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 4 May 2018 15:06:35 +0100 Subject: [PATCH] Avoid repeated tor health warnings --- src/freedombone-utils-onion | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/freedombone-utils-onion b/src/freedombone-utils-onion index 793289c6..350533b2 100755 --- a/src/freedombone-utils-onion +++ b/src/freedombone-utils-onion @@ -314,11 +314,18 @@ function configure_ssh_onion { function check_tor_health { { echo '#!/bin/bash'; echo "status=\$(${PROJECT_NAME}-tor-health)"; + echo "ADMIN_USER=\$(grep \"MY_USERNAME=\" ~/${PROJECT_NAME}.cfg | awk -F '=' '{print \$2}')"; echo "if [[ \"\$status\" == 'G'* ]]; then"; + echo ' if [ -f /tmp/.torfailed ]; then'; + echo ' rm /tmp/.torfailed'; + echo " tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is now \$status\" \$ADMIN_USER@\$HOSTNAME"; + echo ' fi'; echo ' exit 0'; echo 'fi'; - echo "ADMIN_USER=\$(grep \"MY_USERNAME=\" ~/${PROJECT_NAME}.cfg | awk -F '=' '{print \$2}')"; - echo "tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME"; } > /usr/bin/check_tor_health + echo "tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME"; + echo 'if [ ! -f /tmp/.torfailed ]; then'; + echo ' touch /tmp/.torfailed'; + echo 'fi'; } > /usr/bin/check_tor_health chmod +x /usr/bin/check_tor_health if ! grep -q 'check_tor_health' /etc/crontab; then