Skip to content

Commit 2171fae

Browse files
committed
wifi: refactor disable_timeline script, move it from overlay to wifi package
1 parent f083feb commit 2171fae

3 files changed

Lines changed: 43 additions & 26 deletions

File tree

overlay/lower/etc/network/if-pre-up.d/disable_wlan

Lines changed: 0 additions & 26 deletions
This file was deleted.

package/wifi/files/disable_wlan

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
# only work on a WLAN interface
4+
if [ "wlan0" != "$IFACE" ]; then
5+
exit 0
6+
fi
7+
8+
. /usr/share/common
9+
10+
wlan0_missing() {
11+
! test -f /etc/network/interfaces.d/wlan0
12+
}
13+
14+
wlan0_disabled() {
15+
! grep -q '^auto wlan0' /etc/network/interfaces.d/wlan0 > /dev/null
16+
}
17+
18+
wlan0_no_ssid() {
19+
! grep -q 'ssid=' /etc/wpa_supplicant.conf > /dev/null
20+
}
21+
22+
wlan0_no_pass() {
23+
! grep -q 'psk=' /etc/wpa_supplicant.conf > /dev/null
24+
}
25+
26+
# exit 1 to stop the interface from being brought up, and dhcp being attempted
27+
if wlan0_missing; then
28+
echo_error "WLAN interface not configured"
29+
exit 1
30+
elif wlan0_disabled ; then
31+
echo_error "WLAN manually disabled"
32+
exit 1
33+
elif wlan0_no_ssid; then
34+
echo_error "WLAN disabled, no SSID"
35+
exit 1
36+
elif wlan0_no_pass; then
37+
echo_error "WLAN disabled, no password"
38+
exit 1
39+
fi
40+
41+
exit 0

package/wifi/wifi.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ define WIFI_INSTALL_TARGET_CMDS
185185
# Captive Portal
186186
$(INSTALL) -D -m 0644 $(WIFI_PKGDIR)/files/wpa_supplicant.conf \
187187
$(TARGET_DIR)/etc/wpa_supplicant.conf
188+
$(INSTALL) -D -m 0755 $(WIFI_PKGDIR)/files/disable_wlan \
189+
$(TARGET_DIR)/etc/network/if-pre-up.d/disable_wlan
188190
$(INSTALL) -D -m 0644 $(WIFI_PKGDIR)/files/dnsd-portal.conf \
189191
$(TARGET_DIR)/etc/dnsd-portal.conf
190192
$(INSTALL) -D -m 0644 $(WIFI_PKGDIR)/files/httpd-portal.conf \

0 commit comments

Comments
 (0)