Parcourir la source

Handle different tor health statuses

Bob Mottram il y a 6 ans
Parent
révision
5e8046f637
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7
    1
      src/freedombone-utils-onion

+ 7
- 1
src/freedombone-utils-onion Voir le fichier

@@ -324,7 +324,13 @@ function check_tor_health {
324 324
       echo 'fi';
325 325
       echo 'if [ ! -f /tmp/.torfailed ]; then';
326 326
       echo "    tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME";
327
-      echo '    touch /tmp/.torfailed';
327
+      echo "    echo \"\$status\" > /tmp/.torfailed";
328
+      echo 'else';
329
+      echo "    prev_status=\$(cat /tmp/.torfailed)";
330
+      echo "    if [[ \"\$prev_status\" != \"\$status\" ]]; then";
331
+      echo "        tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME";
332
+      echo "        echo \"\$status\" > /tmp/.torfailed";
333
+      echo '    fi';
328 334
       echo 'fi'; } > /usr/bin/check_tor_health
329 335
     chmod +x /usr/bin/check_tor_health
330 336