Kaynağa Gözat

Change interface if on wifi

Bob Mottram 8 yıl önce
ebeveyn
işleme
536c078489
2 değiştirilmiş dosya ile 25 ekleme ve 2 silme
  1. 6
    2
      src/freedombone-app-dlna
  2. 19
    0
      src/freedombone-utils-config

+ 6
- 2
src/freedombone-app-dlna Dosyayı Görüntüle

@@ -199,9 +199,13 @@ function install_dlna_main {
199 199
     fi
200 200
     sed -i 's/#root_container=./root_container=B/g' /etc/minidlna.conf
201 201
     if [[ $SYSTEM_TYPE != "mesh"* ]]; then
202
-        sed -i 's/#network_interface=/network_interface=eth0/g' /etc/minidlna.conf
202
+        if [[ $(config_param_exists WIFI_INTERFACE) == "0" ]]; then
203
+            sed -i 's/#network_interface=/network_interface=eth0/g' /etc/minidlna.conf
204
+        else
205
+            sed -i "s/#network_interface=/network_interface=$WIFI_INTERFACE/g" /etc/minidlna.conf
206
+        fi
203 207
     else
204
-        sed -i 's/#network_interface=/network_interface=$WIFI_INTERFACE/g' /etc/minidlna.conf
208
+        sed -i "s/#network_interface=/network_interface=$WIFI_INTERFACE/g" /etc/minidlna.conf
205 209
     fi
206 210
     sed -i "s/#friendly_name=/friendly_name=\"${PROJECT_NAME} Media\"/g" /etc/minidlna.conf
207 211
     sed -i 's|#db_dir=/var/cache/minidlna|db_dir=/var/cache/minidlna|g' /etc/minidlna.conf

+ 19
- 0
src/freedombone-utils-config Dosyayı Görüntüle

@@ -203,6 +203,25 @@ function read_config_param {
203 203
     fi
204 204
 }
205 205
 
206
+function config_param_exists {
207
+    param_name="$1"
208
+
209
+    if [ ${#param_name} -gt 0 ]; then
210
+        if [ $CONFIGURATION_FILE ]; then
211
+            if [ -f $CONFIGURATION_FILE ]; then
212
+                if grep -q "${param_name}=" $CONFIGURATION_FILE; then
213
+                    param_value=$(cat $CONFIGURATION_FILE | grep "${param_name}=" | head -n 1 | awk -F '=' '{print $2}')
214
+                    if [ ${#param_value} -gt 0 ]; then
215
+                        echo "1"
216
+                        return
217
+                    fi
218
+                fi
219
+            fi
220
+        fi
221
+    fi
222
+    echo "0"
223
+}
224
+
206 225
 function write_config_param {
207 226
     param_name="$1"
208 227
     param_value="$2"