瀏覽代碼

Ensure that the avahi daemon keeps running

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

+ 20
- 1
src/freedombone-utils-avahi 查看文件

@@ -111,7 +111,7 @@ function mesh_avahi {
111 111
     WATCHDOG_SCRIPT_NAME="keepon"
112 112
     { echo '';
113 113
       echo '# keep avahi daemon running';
114
-      echo "AVAHI_RUNNING=\$(pgrep avahi-daemon > /dev/null && echo Running)";
114
+      echo "AVAHI_RUNNING=\$(systemctl is-active avahi-daemon >/dev/null 2>&1 && echo Running)";
115 115
       echo "if [ ! \$AVAHI_RUNNING ]; then";
116 116
       echo '  systemctl start avahi-daemon';
117 117
       echo "  echo -n \$CURRENT_DATE >> \$LOGFILE";
@@ -150,6 +150,25 @@ function install_avahi {
150 150
     sed -i 's|#domain-name=.*|domain-name=local|g' /etc/avahi/avahi-daemon.conf
151 151
     sed -i 's|domain-name=.*|domain-name=local|g' /etc/avahi/avahi-daemon.conf
152 152
 
153
+    # keep the daemon running
154
+    WATCHDOG_SCRIPT_NAME="keepon"
155
+    if [ ! -f "/usr/bin/$WATCHDOG_SCRIPT_NAME" ]; then
156
+        { echo '#!/bin/bash';
157
+          echo 'LOGFILE=/var/log/keepon.log';
158
+          echo "CURRENT_DATE=\$(date)"; } > "/usr/bin/$WATCHDOG_SCRIPT_NAME"
159
+    fi
160
+
161
+    { echo '';
162
+      echo '# keep avahi daemon running';
163
+      echo "AVAHI_RUNNING=\$(systemctl is-active avahi-daemon >/dev/null 2>&1 && echo Running)";
164
+      echo "if [ ! \$AVAHI_RUNNING ]; then";
165
+      echo '  systemctl start avahi-daemon';
166
+      echo "  echo -n \$CURRENT_DATE >> \$LOGFILE";
167
+      echo "  echo \" Avahi daemon restarted\" >> \$LOGFILE";
168
+      echo 'fi';
169
+      echo '# End of avahi'; } >> "/usr/bin/$WATCHDOG_SCRIPT_NAME"
170
+    chmod +x "/usr/bin/$WATCHDOG_SCRIPT_NAME"
171
+
153 172
     mark_completed "${FUNCNAME[0]}"
154 173
 }
155 174