diff --git a/bash/decoders/dump1090-mutability.sh b/bash/decoders/dump1090-mutability.sh index 8f9ceb9..d9ac2a5 100755 --- a/bash/decoders/dump1090-mutability.sh +++ b/bash/decoders/dump1090-mutability.sh @@ -168,7 +168,7 @@ fi # Ask if dump1090-mutability should bind on all IP addresses. if (whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Bind Dump1090-mutability To All IP Addresses" --defaultno --yesno "By default dump1090-mutability is bound only to the local loopback IP address(s) for security reasons. However some people wish to make dump1090-mutability's data accessable externally by other devices. To allow this dump1090-mutability can be configured to listen on all IP addresses bound to this device. It is recommended that unless you plan to access this device from an external source that dump1090-mutability remain bound only to the local loopback IP address(s).\n\nWould you like dump1090-mutability to listen on all IP addesses?" 15 78) then echo -e "\e[94m Binding dump1090-mutability to all available IP addresses...\e[97m" - ChangeConfig "NET_BIND_ADDRESS" "0.0.0.0" "/etc/default/dump1090-mutability" + CommentConfig "NET_BIND_ADDRESS" "0.0.0.0" "/etc/default/dump1090-mutability" else echo -e "\e[94m Binding dump1090-mutability to the localhost IP addresses...\e[97m" ChangeConfig "NET_BIND_ADDRESS" "127.0.0.1" "/etc/default/dump1090-mutability" diff --git a/bash/functions.sh b/bash/functions.sh index 2522fb8..745b3a5 100755 --- a/bash/functions.sh +++ b/bash/functions.sh @@ -97,3 +97,13 @@ function GetConfig { sudo sed -n '/^$1=\(.*\)$/s//\1/p' $2 echo `sed -n "/^$1=\"\(.*\)\"$/s//\1/p" $2` } + +function CommentConfig { + # Use sed to locate the "KEY" then comment out the line containing it in the specified "FILE". + sudo sed -i -e "/$1/s/^#*/#/" $2 +} + +function UncommentConfig { + # Use sed to locate the "KEY" then uncomment the line containing it in the specified "FILE". + sudo sed -i -e "/$1/s/^#//" $2 +}