Change interface if on wifi

This commit is contained in:
Bob Mottram 2016-10-21 10:43:50 +01:00
parent 119bd00f7b
commit 536c078489
2 changed files with 25 additions and 2 deletions

View File

@ -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
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
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
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

View File

@ -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"