浏览代码

cron entry to check tor health and report via email

Bob Mottram 7 年前
父节点
当前提交
d3869f5350
共有 2 个文件被更改,包括 18 次插入0 次删除
  1. 15
    0
      src/freedombone-utils-onion
  2. 3
    0
      src/freedombone-utils-setup

+ 15
- 0
src/freedombone-utils-onion 查看文件

311
     mark_completed "${FUNCNAME[0]}"
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
 function install_tor {
329
 function install_tor {
315
     if [[ $SYSTEM_TYPE == "mesh*" ]]; then
330
     if [[ $SYSTEM_TYPE == "mesh*" ]]; then
316
         return
331
         return

+ 3
- 0
src/freedombone-utils-setup 查看文件

971
     function_check install_tor
971
     function_check install_tor
972
     install_tor
972
     install_tor
973
 
973
 
974
+    function_check check_tor_health
975
+    check_tor_health
976
+
974
     function_check install_command_line_browser
977
     function_check install_command_line_browser
975
     install_command_line_browser
978
     install_command_line_browser
976
 
979