Skip to content

Commit

Permalink
wrt: Configure Wi-Fi repeater using AP+STA mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wagdav committed Aug 17, 2024
1 parent 9e27c01 commit c5631d3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions router/config-ap-sta
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
# Setup Wi-Fi Repeater using AP+STA mode
# Reference: https://openwrt.org/docs/guide-user/network/wifi/wifiextenders/ap_sta
set -o errexit

if [ "$#" -ne 2 ]; then
echo "Usage: $0 WIFI_SSID WIFI_KEY" >&2
exit 1
fi

WIFI_SSID="$1"
WIFI_KEY="$2"

# Add the WWAN network is in the WAN firewall zone
while uci -q delete firewall.@zone[1].network; do :; done
uci add_list firewall.@zone[1].network="wan"
uci add_list firewall.@zone[1].network="wan6"
uci add_list firewall.@zone[1].network="wwan"

# The WWAN interface is the "uplink". It obtains a DHCP address from the upstream hotspot.
uci set network.wwan="interface"
uci set network.wwan.proto="dhcp"

# Add the Wi-Fi interface for the uplink.
uci set wireless.wwan="wifi-iface"
uci set wireless.wwan.device="radio0"
uci set wireless.wwan.network="wwan"
uci set wireless.wwan.mode="sta"

uci set wireless.wwan.encryption="psk2"
uci set wireless.wwan.ssid="$WIFI_SSID"
uci set wireless.wwan.key="$WIFI_KEY"

CHANGES=$(uci changes)
if [ -n "$CHANGES" ]; then
echo "Changes:"
uci changes
echo ""
echo ""
echo "This script doesn't restart any services. You may need to run:"
echo "- service firewall restart"
echo "- service network restart"
echo "- wifi reload"
echo ""
echo "Or just reboot the device"
else
echo "No changes. Configuration is up-to-date!"
fi
uci commit
2 changes: 1 addition & 1 deletion router/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ HERE=$(dirname "$(readlink -f "$0")")
$SSH_COMMAND sh -s \
"$(printf "%q" "$(pass Home/wifi_ssid)")" \
"$(printf "%q" "$(pass Home/wifi_key)")" \
< "$HERE"/config
< <(cat "$HERE"/config "$HERE"/config-ap-sta)

0 comments on commit c5631d3

Please sign in to comment.