Avoid repeated tor health warnings

This commit is contained in:
Bob Mottram 2018-05-04 15:06:35 +01:00
parent d3869f5350
commit 59af1821b9
1 changed files with 9 additions and 2 deletions

View File

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