Browse Source

cron entry to check tor health and report via email

Bob Mottram 6 years ago
parent
commit
d3869f5350
2 changed files with 18 additions and 0 deletions
  1. 15
    0
      src/freedombone-utils-onion
  2. 3
    0
      src/freedombone-utils-setup

+ 15
- 0
src/freedombone-utils-onion View File

@@ -311,6 +311,21 @@ function configure_ssh_onion {
311 311
     mark_completed "${FUNCNAME[0]}"
312 312
 }
313 313
 
314
+function check_tor_health {
315
+    { echo '#!/bin/bash';
316
+      echo "status=\$(${PROJECT_NAME}-tor-health)";
317
+      echo "if [[ \"\$status\" == 'G'* ]]; then";
318
+      echo '    exit 0';
319
+      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
322
+    chmod +x /usr/bin/check_tor_health
323
+
324
+    if ! grep -q 'check_tor_health' /etc/crontab; then
325
+        cron_add_mins 10 "/usr/bin/check_tor_health"
326
+    fi
327
+}
328
+
314 329
 function install_tor {
315 330
     if [[ $SYSTEM_TYPE == "mesh*" ]]; then
316 331
         return

+ 3
- 0
src/freedombone-utils-setup View File

@@ -971,6 +971,9 @@ function setup_utils {
971 971
     function_check install_tor
972 972
     install_tor
973 973
 
974
+    function_check check_tor_health
975
+    check_tor_health
976
+
974 977
     function_check install_command_line_browser
975 978
     install_command_line_browser
976 979