From d3869f53507a9f024a083b5cfce7ee22a30d4b3d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 4 May 2018 14:49:15 +0100 Subject: [PATCH] cron entry to check tor health and report via email --- src/freedombone-utils-onion | 15 +++++++++++++++ src/freedombone-utils-setup | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/freedombone-utils-onion b/src/freedombone-utils-onion index b0cf04f8..793289c6 100755 --- a/src/freedombone-utils-onion +++ b/src/freedombone-utils-onion @@ -311,6 +311,21 @@ function configure_ssh_onion { mark_completed "${FUNCNAME[0]}" } +function check_tor_health { + { echo '#!/bin/bash'; + echo "status=\$(${PROJECT_NAME}-tor-health)"; + echo "if [[ \"\$status\" == 'G'* ]]; then"; + 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 + chmod +x /usr/bin/check_tor_health + + if ! grep -q 'check_tor_health' /etc/crontab; then + cron_add_mins 10 "/usr/bin/check_tor_health" + fi +} + function install_tor { if [[ $SYSTEM_TYPE == "mesh*" ]]; then return diff --git a/src/freedombone-utils-setup b/src/freedombone-utils-setup index 8c40ed8a..88937781 100755 --- a/src/freedombone-utils-setup +++ b/src/freedombone-utils-setup @@ -971,6 +971,9 @@ function setup_utils { function_check install_tor install_tor + function_check check_tor_health + check_tor_health + function_check install_command_line_browser install_command_line_browser