From 536c078489aa6605e214a3d00124e8a2c77b4b1b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 21 Oct 2016 10:43:50 +0100 Subject: [PATCH] Change interface if on wifi --- src/freedombone-app-dlna | 8 ++++++-- src/freedombone-utils-config | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/freedombone-app-dlna b/src/freedombone-app-dlna index 9f188d92..160f747d 100755 --- a/src/freedombone-app-dlna +++ b/src/freedombone-app-dlna @@ -199,9 +199,13 @@ function install_dlna_main { fi sed -i 's/#root_container=./root_container=B/g' /etc/minidlna.conf if [[ $SYSTEM_TYPE != "mesh"* ]]; then - sed -i 's/#network_interface=/network_interface=eth0/g' /etc/minidlna.conf + if [[ $(config_param_exists WIFI_INTERFACE) == "0" ]]; then + sed -i 's/#network_interface=/network_interface=eth0/g' /etc/minidlna.conf + else + sed -i "s/#network_interface=/network_interface=$WIFI_INTERFACE/g" /etc/minidlna.conf + fi else - sed -i 's/#network_interface=/network_interface=$WIFI_INTERFACE/g' /etc/minidlna.conf + sed -i "s/#network_interface=/network_interface=$WIFI_INTERFACE/g" /etc/minidlna.conf fi sed -i "s/#friendly_name=/friendly_name=\"${PROJECT_NAME} Media\"/g" /etc/minidlna.conf sed -i 's|#db_dir=/var/cache/minidlna|db_dir=/var/cache/minidlna|g' /etc/minidlna.conf diff --git a/src/freedombone-utils-config b/src/freedombone-utils-config index 37486e63..463afc8f 100755 --- a/src/freedombone-utils-config +++ b/src/freedombone-utils-config @@ -203,6 +203,25 @@ function read_config_param { fi } +function config_param_exists { + param_name="$1" + + if [ ${#param_name} -gt 0 ]; then + if [ $CONFIGURATION_FILE ]; then + if [ -f $CONFIGURATION_FILE ]; then + if grep -q "${param_name}=" $CONFIGURATION_FILE; then + param_value=$(cat $CONFIGURATION_FILE | grep "${param_name}=" | head -n 1 | awk -F '=' '{print $2}') + if [ ${#param_value} -gt 0 ]; then + echo "1" + return + fi + fi + fi + fi + fi + echo "0" +} + function write_config_param { param_name="$1" param_value="$2"