1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Automated ssid and country code updates

This commit is contained in:
Federico Frigo 2021-10-19 18:51:44 +02:00
parent d0c14824e1
commit fd1c48b710
2 changed files with 41 additions and 25 deletions

View File

@ -12,6 +12,7 @@ interface=uap0
wpa=2
wpa_pairwise=CCMP
country_code=IT
ignore_broadcast_ssid=0
## Rapberry Pi 3 specific to on board WLAN/WiFi
#ieee80211n=1 # 802.11n support (Raspberry Pi 3)
#wmm_enabled=1 # QoS support (Raspberry Pi 3)
@ -22,4 +23,3 @@ country_code=IT
## RaspAP bridge AP mode (disabled by default)
#bridge=br0
ignore_broadcast_ssid=0

View File

@ -10,8 +10,7 @@ DAEMONPATH="/lib/systemd/system/raspapd.service"
OPENVPNENABLED=$(pidof openvpn | wc -l)
positional=()
while [[ $# -gt 0 ]]
do
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
@ -48,6 +47,24 @@ if [ "${action}" = "stop" ]; then
exit 0
fi
HOSTAPD_CONF="/etc/hostapd/hostapd.conf"
old_ssid=$(grep ^ssid $HOSTAPD_CONF | cut -d "=" -f 2)
new_ssid="isobox-$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2)"
if [[ "$old_ssid" != "$new_ssid" ]]; then
sed -i "s/$old_ssid/$new_ssid/" $HOSTAPD_CONF
echo "Updated ssid: $new_ssid"
fi
new_country_code=$(curl -s -H "Authorization: Bearer 9da1eb466ed052" https://ipinfo.io/json | jq -r ".country // empty")
old_country_code=$(grep ^country_code $HOSTAPD_CONF | cut -d "=" -f 2)
if [[ ! -z "$new_country_code" ]] && [[ "$old_country_code" != "$new_country_code" ]]; then
sed -i "s/$old_country_code/$new_country_code/" $HOSTAPD_CONF
echo "Updated country code: $new_country_code"
fi
if [ -f "$DAEMONPATH" ] && [ ! -z "$interface" ]; then
echo "Changing RaspAP Daemon --interface to $interface"
sed -i "s/\(--interface \)[[:alnum:]]*/\1$interface/" "$DAEMONPATH"
@ -127,4 +144,3 @@ if [ "${config[WifiAPEnable]}" = 1 ]; then
fi
echo "RaspAP service start DONE"