From c1dcfba83c752d7cf6c7839e525a2f7c0f7f68c2 Mon Sep 17 00:00:00 2001 From: garywill Date: Wed, 20 Jan 2021 13:10:02 +0800 Subject: [PATCH] seperate functions: 1 writing hostapd conf 2 changing wifi country 3 checking wifi chennel --- lnxrouter | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) mode change 100644 => 100755 lnxrouter diff --git a/lnxrouter b/lnxrouter old mode 100644 new mode 100755 index 8efc722..9616021 --- a/lnxrouter +++ b/lnxrouter @@ -1516,16 +1516,7 @@ decide_subnet_interface() { fi } -write_hostapd_conf() { - if [[ -n "$COUNTRY" && $USE_IWCONFIG -eq 0 ]]; then - iw reg set "$COUNTRY" - fi - - can_transmit_to_channel ${AP_IFACE} ${CHANNEL} || die "Your adapter can not transmit to channel ${CHANNEL}, frequency band ${FREQ_BAND}GHz." - - # TODO: move above code - - # hostapd config +write_hostapd_conf() { cat <<- EOF > "$CONFDIR/hostapd.conf" beacon_int=100 ssid=${SSID} @@ -1816,6 +1807,14 @@ decide_subnet_interface echo "$SUBNET_IFACE" > "$CONFDIR/subn_iface" +if [[ $WIFI_IFACE && -n "$COUNTRY" && $USE_IWCONFIG -eq 0 ]]; then + iw reg set "$COUNTRY" || die "Failed setting country code" +fi + +if [[ $WIFI_IFACE ]] ; then + can_transmit_to_channel ${AP_IFACE} ${CHANNEL} || die "Your adapter can not transmit to channel ${CHANNEL}, frequency band ${FREQ_BAND}GHz." +fi + [[ $WIFI_IFACE ]] && write_hostapd_conf #=================================================== #===================================================