Bob Mottram 6 years ago
parent
commit
77795c542f
2 changed files with 26 additions and 19 deletions
  1. 23
    19
      src/freedombone-utils-avahi
  2. 3
    0
      src/freedombone-utils-setup

+ 23
- 19
src/freedombone-utils-avahi View File

@@ -120,6 +120,29 @@ function mesh_avahi {
120 120
     chmod +x "$rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME"
121 121
 }
122 122
 
123
+function keep_avahi_running {
124
+    WATCHDOG_SCRIPT_NAME="keepon"
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"
130
+    fi
131
+
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
144
+}
145
+
123 146
 function install_avahi {
124 147
     if [ "$INSTALLING_MESH" ]; then
125 148
         mesh_avahi
@@ -150,25 +173,6 @@ function install_avahi {
150 173
     sed -i 's|#domain-name=.*|domain-name=local|g' /etc/avahi/avahi-daemon.conf
151 174
     sed -i 's|domain-name=.*|domain-name=local|g' /etc/avahi/avahi-daemon.conf
152 175
 
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
-
172 176
     mark_completed "${FUNCNAME[0]}"
173 177
 }
174 178
 

+ 3
- 0
src/freedombone-utils-setup View File

@@ -1055,6 +1055,9 @@ function setup_utils {
1055 1055
     function_check install_avahi
1056 1056
     install_avahi
1057 1057
 
1058
+    function_check keep_avahi_running
1059
+    keep_avahi_running
1060
+
1058 1061
     function_check create_avahi_onion_domains
1059 1062
     create_avahi_onion_domains
1060 1063