This commit is contained in:
Bob Mottram 2018-05-27 11:39:59 +01:00
parent 77795c542f
commit cc875c00fe
1 changed files with 12 additions and 16 deletions

View File

@ -123,24 +123,20 @@ function mesh_avahi {
function keep_avahi_running {
WATCHDOG_SCRIPT_NAME="keepon"
if [ ! -f "/usr/bin/$WATCHDOG_SCRIPT_NAME" ]; then
{ echo '#!/bin/bash';
echo 'LOGFILE=/var/log/keepon.log';
echo "CURRENT_DATE=\$(date)"; } > "/usr/bin/$WATCHDOG_SCRIPT_NAME"
if grep -q "avahi daemon" "/usr/bin/$WATCHDOG_SCRIPT_NAME"; then
return
fi
if ! grep -q "avahi daemon" "/usr/bin/$WATCHDOG_SCRIPT_NAME"; then
{ echo '';
echo '# keep avahi daemon running';
echo "AVAHI_RUNNING=\$(systemctl is-active avahi-daemon >/dev/null 2>&1 && echo Running)";
echo "if [ ! \$AVAHI_RUNNING ]; then";
echo ' systemctl start avahi-daemon';
echo " echo -n \$CURRENT_DATE >> \$LOGFILE";
echo " echo \" Avahi daemon restarted\" >> \$LOGFILE";
echo 'fi';
echo '# End of avahi'; } >> "/usr/bin/$WATCHDOG_SCRIPT_NAME"
chmod +x "/usr/bin/$WATCHDOG_SCRIPT_NAME"
fi
{ echo '';
echo '# keep avahi daemon running';
echo "AVAHI_RUNNING=\$(systemctl is-active avahi-daemon >/dev/null 2>&1 && echo Running)";
echo "if [ ! \$AVAHI_RUNNING ]; then";
echo ' systemctl start avahi-daemon';
echo " echo -n \$CURRENT_DATE >> \$LOGFILE";
echo " echo \" Avahi daemon restarted\" >> \$LOGFILE";
echo 'fi';
echo '# End of avahi'; } >> "/usr/bin/$WATCHDOG_SCRIPT_NAME"
chmod +x "/usr/bin/$WATCHDOG_SCRIPT_NAME"
}
function install_avahi {