Skip to content

Commit

Permalink
don't rely on hostapd radio name starting with phy
Browse files Browse the repository at this point in the history
some devices have a radio named wl0 and wl1 instead in openwrt 23.05
This is a workaround, until a better fix using lua is available

fixes #39
  • Loading branch information
maurerle committed Jun 10, 2024
1 parent f1e4678 commit 946e6a0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ffac-ssid-changer/shsrc/ssid-changer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SETTINGS_DEBUG_LOGGING="$(uci -q get ssid-changer.settings.debug_log_enabled)"
pgrep -f autoupdater >/dev/null && safety_exit 'autoupdater running'
UT=$(sed 's/\..*//g' /proc/uptime)
[ "$UT" -gt 60 ] || safety_exit 'less than one minute'
[ "$(find /var/run -name "hostapd-phy*" | wc -l)" -gt 0 ] || safety_exit 'no hostapd-phy*'
[ "$(find /var/run -name "hostapd-*" | wc -l)" -gt 0 ] || safety_exit 'no hostapd-*'

# only once every timeframe minutes the SSID will change to the Offline-SSID
# (set to 1 minute to change immediately every time the router gets offline)
Expand Down Expand Up @@ -132,8 +132,8 @@ if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
log_debug "node is online"
LOOP=1
# check status for all physical devices
for HOSTAPD in /var/run/hostapd-phy*; do
[ -e "$HOSTAPD" ] || break # handle the case of no hostapd-phy* files
for HOSTAPD in /var/run/hostapd-*; do
[ -e "$HOSTAPD" ] || break # handle the case of no hostapd-* files
# shellcheck disable=SC2086 # ONLINE_SSIDs has multiple lines
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
LOOP=$((LOOP+1))
Expand Down Expand Up @@ -178,8 +178,8 @@ elif [ "$CHECK" -eq 0 ]; then
if [ "$OFF_COUNT" -ge $((T / 2)) ]; then
# node was offline more times than half of switch_timeframe (or than $FIRST)
LOOP=1
for HOSTAPD in /var/run/hostapd-phy*; do
[ -e "$HOSTAPD" ] || break # handle the case of no hostapd-phy* files
for HOSTAPD in /var/run/hostapd-*; do
[ -e "$HOSTAPD" ] || break # handle the case of no hostapd-* files
# shellcheck disable=SC2086 # ONLINE_SSIDs has multiple lines
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
LOOP=$((LOOP+1))
Expand Down

0 comments on commit 946e6a0

Please sign in to comment.