Bob Mottram 6 年之前
父節點
當前提交
cc875c00fe
共有 1 個檔案被更改,包括 12 行新增16 行删除
  1. 12
    16
      src/freedombone-utils-avahi

+ 12
- 16
src/freedombone-utils-avahi 查看文件

@@ -123,24 +123,20 @@ function mesh_avahi {
123 123
 function keep_avahi_running {
124 124
     WATCHDOG_SCRIPT_NAME="keepon"
125 125
 
126
-    if [ ! -f "/usr/bin/$WATCHDOG_SCRIPT_NAME" ]; then
127
-        { echo '#!/bin/bash';
128
-          echo 'LOGFILE=/var/log/keepon.log';
129
-          echo "CURRENT_DATE=\$(date)"; } > "/usr/bin/$WATCHDOG_SCRIPT_NAME"
126
+    if grep -q "avahi daemon" "/usr/bin/$WATCHDOG_SCRIPT_NAME"; then
127
+        return
130 128
     fi
131 129
 
132
-    if ! grep -q "avahi daemon" "/usr/bin/$WATCHDOG_SCRIPT_NAME"; then
133
-        { echo '';
134
-          echo '# keep avahi daemon running';
135
-          echo "AVAHI_RUNNING=\$(systemctl is-active avahi-daemon >/dev/null 2>&1 && echo Running)";
136
-          echo "if [ ! \$AVAHI_RUNNING ]; then";
137
-          echo '  systemctl start avahi-daemon';
138
-          echo "  echo -n \$CURRENT_DATE >> \$LOGFILE";
139
-          echo "  echo \" Avahi daemon restarted\" >> \$LOGFILE";
140
-          echo 'fi';
141
-          echo '# End of avahi'; } >> "/usr/bin/$WATCHDOG_SCRIPT_NAME"
142
-        chmod +x "/usr/bin/$WATCHDOG_SCRIPT_NAME"
143
-    fi
130
+    { echo '';
131
+      echo '# keep avahi daemon running';
132
+      echo "AVAHI_RUNNING=\$(systemctl is-active avahi-daemon >/dev/null 2>&1 && echo Running)";
133
+      echo "if [ ! \$AVAHI_RUNNING ]; then";
134
+      echo '  systemctl start avahi-daemon';
135
+      echo "  echo -n \$CURRENT_DATE >> \$LOGFILE";
136
+      echo "  echo \" Avahi daemon restarted\" >> \$LOGFILE";
137
+      echo 'fi';
138
+      echo '# End of avahi'; } >> "/usr/bin/$WATCHDOG_SCRIPT_NAME"
139
+    chmod +x "/usr/bin/$WATCHDOG_SCRIPT_NAME"
144 140
 }
145 141
 
146 142
 function install_avahi {