fff-wireless: Add gateway configuration scripts

Submitted by Fabian Blaese on Sept. 8, 2019, 1:09 p.m.

Details

Message ID 20190908130906.17964-1-fabian@blaese.de
State New
Headers show

Commit Message

Fabian Blaese Sept. 8, 2019, 1:09 p.m.
---
 .../fff-wireless/files/etc/gateway.d/28-wifi  | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi b/src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi
new file mode 100644
index 0000000..6158c29
--- /dev/null
+++ b/src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi
@@ -0,0 +1,57 @@ 
+. /lib/functions/fff/wireless
+
+configure() {
+	# get parameters
+	essid=$(uci -q get gateway.@client[0].essid)
+	chan2ghz=$(uci -q get gateway.@client[0].chan2ghz)
+	chan5ghz=$(uci -q get gateway.@client[0].chan5ghz)
+
+	if [ -z "$essid" ]; then
+		echo "WARNING: No ESSID set! WiFi AP is disabled"
+	fi
+
+	for radio in $(wifiListRadio); do
+		freq="$(wifiGetFreq $radio)"
+		disabled=1
+
+		# Delete wXmesh, wXconfigap
+		uci -q del wireless.w${freq}mesh
+		uci -q del wireless.w${freq}configap
+
+		if [ -n "$essid" ]; then
+			# set channel for 5ghz
+			if [ "$freq" = "5" ]; then
+				if [ -z "$chan5ghz" ]; then
+					echo "WARNING: No 5 GHz channel set! Disabling AP on $radio"
+				else
+					uci set wireless.${radio}.channel="$chan5ghz"
+					disabled=0
+				fi
+			fi
+
+			# set channel for 2.4ghz
+			if [ "$freq" = "2" ]; then
+				if [ -z "$chan2ghz" ]; then
+					echo "WARNING: No 2.4 GHz channel set! Disabling AP on $radio"
+				else
+					uci set wireless.${radio}.channel="$chan2ghz"
+					disabled=0
+				fi
+			fi
+
+			# set essid
+			uci set wireless.w${freq}ap.ssid="$essid"
+		fi
+
+		# enable or disable ap interface appropriately. The radios 'disabled'-option is not touched
+		uci set wireless.w${freq}ap.disabled="$disabled"
+	done
+}
+
+apply() {
+	uci commit wireless
+}
+
+revert() {
+	uci revert wireless
+}

Comments

Fabian Blaese Sept. 8, 2019, 8:10 p.m.
Signed-off-by: Fabian Bläse <fabian@blaese.de>
Christian Dresel Oct. 4, 2019, 10:30 a.m.
hi

Reviewed-by: Christian Dresel <fff@chrisi01.de>

Gruß

Christian

On 08.09.19 15:09, Fabian Bläse wrote:
> ---
>  .../fff-wireless/files/etc/gateway.d/28-wifi  | 57 +++++++++++++++++++
>  1 file changed, 57 insertions(+)
>  create mode 100644 src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi
> 
> diff --git a/src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi b/src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi
> new file mode 100644
> index 0000000..6158c29
> --- /dev/null
> +++ b/src/packages/fff/fff-wireless/files/etc/gateway.d/28-wifi
> @@ -0,0 +1,57 @@
> +. /lib/functions/fff/wireless
> +
> +configure() {
> +	# get parameters
> +	essid=$(uci -q get gateway.@client[0].essid)
> +	chan2ghz=$(uci -q get gateway.@client[0].chan2ghz)
> +	chan5ghz=$(uci -q get gateway.@client[0].chan5ghz)
> +
> +	if [ -z "$essid" ]; then
> +		echo "WARNING: No ESSID set! WiFi AP is disabled"
> +	fi
> +
> +	for radio in $(wifiListRadio); do
> +		freq="$(wifiGetFreq $radio)"
> +		disabled=1
> +
> +		# Delete wXmesh, wXconfigap
> +		uci -q del wireless.w${freq}mesh
> +		uci -q del wireless.w${freq}configap
> +
> +		if [ -n "$essid" ]; then
> +			# set channel for 5ghz
> +			if [ "$freq" = "5" ]; then
> +				if [ -z "$chan5ghz" ]; then
> +					echo "WARNING: No 5 GHz channel set! Disabling AP on $radio"
> +				else
> +					uci set wireless.${radio}.channel="$chan5ghz"
> +					disabled=0
> +				fi
> +			fi
> +
> +			# set channel for 2.4ghz
> +			if [ "$freq" = "2" ]; then
> +				if [ -z "$chan2ghz" ]; then
> +					echo "WARNING: No 2.4 GHz channel set! Disabling AP on $radio"
> +				else
> +					uci set wireless.${radio}.channel="$chan2ghz"
> +					disabled=0
> +				fi
> +			fi
> +
> +			# set essid
> +			uci set wireless.w${freq}ap.ssid="$essid"
> +		fi
> +
> +		# enable or disable ap interface appropriately. The radios 'disabled'-option is not touched
> +		uci set wireless.w${freq}ap.disabled="$disabled"
> +	done
> +}
> +
> +apply() {
> +	uci commit wireless
> +}
> +
> +revert() {
> +	uci revert wireless
> +}
>