Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 45357ae4d2 | |||
| 1eb5e17ee7 | |||
| 7356dce619 |
2 changed files with 28 additions and 6 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
CLAUDE.local.md
|
||||||
|
STATUS.md
|
||||||
32
omatether.sh
32
omatether.sh
|
|
@ -71,6 +71,21 @@ net_test() {
|
||||||
curl -sf --interface "$iface" --max-time 5 -o /dev/null https://www.google.com
|
curl -sf --interface "$iface" --max-time 5 -o /dev/null https://www.google.com
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Poll until the tether has an IP and working internet, or time out (arg:
|
||||||
|
# seconds). First plug-in after a reboot can take 20-30s before iOS brings
|
||||||
|
# the interface up and DHCP completes — a fixed short sleep reports false
|
||||||
|
# "enable hotspot" advice.
|
||||||
|
tether_wait() {
|
||||||
|
local deadline=$(( SECONDS + ${1:-45} )) iface
|
||||||
|
while (( SECONDS < deadline )); do
|
||||||
|
if iface=$(tether_iface) && [[ -n $(tether_ip "$iface") ]] && net_test "$iface"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# usbmuxd drops devices that were plugged in before it started
|
# usbmuxd drops devices that were plugged in before it started
|
||||||
# ("device unconfigured") — a restart rescans the bus.
|
# ("device unconfigured") — a restart rescans the bus.
|
||||||
revive_usbmuxd() {
|
revive_usbmuxd() {
|
||||||
|
|
@ -382,14 +397,19 @@ tui_connect() {
|
||||||
ok "Paired with $(phone_name)"
|
ok "Paired with $(phone_name)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Give networkd a moment to DHCP the freshly-authorised interface.
|
# Poll for the connection — first plug-in after a reboot can take 20-30s
|
||||||
|
# (functions exported so the gum spin child shell can run them).
|
||||||
local iface=""
|
local iface=""
|
||||||
gum spin --title "Bringing the connection up…" -- sleep 4 || true
|
export -f tether_wait tether_iface tether_ip net_test
|
||||||
if iface=$(tether_iface) && [[ -n $(tether_ip "$iface") ]] && net_test "$iface"; then
|
if gum spin --title "Bringing the connection up… (can take ~30s after a reboot)" -- \
|
||||||
ok "Connected — internet available through the phone ($iface)"
|
bash -c 'tether_wait 45'; then
|
||||||
|
iface=$(tether_iface || true)
|
||||||
|
ok "Connected — internet available through the phone (${iface:-tether})"
|
||||||
else
|
else
|
||||||
warn "Paired, but no connection yet. On the phone enable:"
|
warn "Paired, but the phone hasn't offered a connection yet. Check:"
|
||||||
say " Settings → Personal Hotspot → Allow Others to Join: ON"
|
say " • Settings → Personal Hotspot → Allow Others to Join: ON"
|
||||||
|
say " • Unlock the phone once (needed after a phone restart)"
|
||||||
|
say " • Still nothing? Unplug and replug the cable, then Connect again."
|
||||||
fi
|
fi
|
||||||
pause
|
pause
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue