-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrescue-ap
executable file
·52 lines (42 loc) · 1.24 KB
/
rescue-ap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh /etc/rc.common
#
# (C) 2024 Hajo Noerenberg
#
# http://www.noerenberg.de/
# https://github.com/hn/linkplay-a31
#
START=99
rescueap_watchdog() {
logger -t rescue-ap "Delaying check for network connectivity"
sleep 3m
logger -t rescue-ap "Checking for network connectivity (default route)"
route -n | grep -q ^0.0.0.0
if [ $? -eq 0 ]; then
logger -t rescue-ap "Network connectivity is ok, exiting"
/etc/init.d/sysntpd restart
exit 0
fi
logger -t rescue-ap "No network connectivity, enabling rescue access point"
/etc/init.d/network stop
[ -x /etc/init.d/firewall ] && /etc/init.d/firewall stop
iw phy phy0 interface add phy0-ap0 type __ap
ip addr add 192.168.31.1/24 dev phy0-ap0
ujail -t 5 -n hostapd -U network -G network -C /etc/capabilities/wpad.json -c -- \
/usr/sbin/hostapd -B -s -g /var/run/hostapd/global /etc/hostapd-rescue.conf
logger -t rescue-ap "Successfully setup rescue access point"
sleep 10m
if [ -f /tmp/rescue-ap ]; then
logger -t rescue-ap "Admin login detected, exiting"
exit 0
fi
logger -t rescue-ap "Timeout, rebooting system"
reboot
}
boot() {
mount | grep -q squashfs
if [ $? -eq 0 ]; then
rescueap_watchdog &
else
logger -t rescue-ap "No rescue access point for system booted from RAM"
fi
}