Browse Source

Avoid repeated tor health warnings

Bob Mottram 6 years ago
parent
commit
59af1821b9
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      src/freedombone-utils-onion

+ 9
- 2
src/freedombone-utils-onion View File

@@ -314,11 +314,18 @@ function configure_ssh_onion {
314 314
 function check_tor_health {
315 315
     { echo '#!/bin/bash';
316 316
       echo "status=\$(${PROJECT_NAME}-tor-health)";
317
+      echo "ADMIN_USER=\$(grep \"MY_USERNAME=\" ~/${PROJECT_NAME}.cfg | awk -F '=' '{print \$2}')";
317 318
       echo "if [[ \"\$status\" == 'G'* ]]; then";
319
+      echo '    if [ -f /tmp/.torfailed ]; then';
320
+      echo '        rm /tmp/.torfailed';
321
+      echo "        tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is now \$status\" \$ADMIN_USER@\$HOSTNAME";
322
+      echo '    fi';
318 323
       echo '    exit 0';
319 324
       echo 'fi';
320
-      echo "ADMIN_USER=\$(grep \"MY_USERNAME=\" ~/${PROJECT_NAME}.cfg | awk -F '=' '{print \$2}')";
321
-      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
325
+      echo "tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME";
326
+      echo 'if [ ! -f /tmp/.torfailed ]; then';
327
+      echo '    touch /tmp/.torfailed';
328
+      echo 'fi'; } > /usr/bin/check_tor_health
322 329
     chmod +x /usr/bin/check_tor_health
323 330
 
324 331
     if ! grep -q 'check_tor_health' /etc/crontab; then