This commit is contained in:
Bob Mottram 2018-05-27 11:36:17 +01:00
parent fc004e746f
commit 77795c542f
2 changed files with 26 additions and 19 deletions

View File

@ -120,6 +120,29 @@ function mesh_avahi {
chmod +x "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
}
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"
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
}
function install_avahi {
if [ "$INSTALLING_MESH" ]; then
mesh_avahi
@ -150,25 +173,6 @@ function install_avahi {
sed -i 's|#domain-name=.*|domain-name=local|g' /etc/avahi/avahi-daemon.conf
sed -i 's|domain-name=.*|domain-name=local|g' /etc/avahi/avahi-daemon.conf
# keep the daemon 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"
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"
mark_completed "${FUNCNAME[0]}"
}

View File

@ -1055,6 +1055,9 @@ function setup_utils {
function_check install_avahi
install_avahi
function_check keep_avahi_running
keep_avahi_running
function_check create_avahi_onion_domains
create_avahi_onion_domains