Keep attempting to bring up the network
After a total power outage (system and networking gear), it's possible that the system boots up and blow through all the timeouts for DHCP before the network is operational. Unfortunately, I can't always solve that.
This commit is contained in:
7
debian/changelog
vendored
7
debian/changelog
vendored
@@ -1,3 +1,10 @@
|
||||
tailscale-initramfs (0.2) unstable; urgency=medium
|
||||
|
||||
* Keep trying to bring up the network until it either comes up or the boot
|
||||
process continues.
|
||||
|
||||
-- Paul Aurich <paul@darkrain42.org> Tue, 06 Dec 2022 20:12:18 -0800
|
||||
|
||||
tailscale-initramfs (0.1) unstable; urgency=medium
|
||||
|
||||
* Initial Release.
|
||||
|
||||
@@ -33,6 +33,7 @@ wait_for_tailscaled()
|
||||
# SC3043: In POSIX sh, 'local' is undefined.
|
||||
local pid exe timer="$TAILSCALE_SHUTDOWN_TIMEOUT"
|
||||
pid="$(cat "$PIDFILE" 2>/dev/null)" || return 1
|
||||
rm -f "$PIDFILE"
|
||||
|
||||
while [ $timer -gt 0 ] && exe="$(readlink -f "/proc/$pid/exe" 2>/dev/null)"; do
|
||||
if [ "$exe" = "$EXE" ]; then
|
||||
@@ -60,8 +61,6 @@ if PID="$(wait_for_tailscaled)"; then
|
||||
log_end_msg
|
||||
fi
|
||||
|
||||
rm -f "$PIDFILE"
|
||||
|
||||
if [ "$BOOT" != nfs ] && [ "$IFDOWN" != none ]; then
|
||||
for IFACE in /sys/class/net/$IFDOWN; do
|
||||
[ -e "$IFACE" ] || continue
|
||||
|
||||
@@ -19,6 +19,8 @@ esac
|
||||
|
||||
. /scripts/functions
|
||||
|
||||
PIDFILE="/run/tailscale.pid"
|
||||
|
||||
if [ -e /etc/tailscale/initramfs/config ]; then
|
||||
. /etc/tailscale/initramfs/config
|
||||
fi
|
||||
@@ -33,6 +35,16 @@ if [ -z "${TAILSCALE_HOSTNAME-}" ]; then
|
||||
TAILSCALE_HOSTNAME=${HOSTNAME}-initramfs
|
||||
fi
|
||||
|
||||
network_up()
|
||||
{
|
||||
for conf in /run/net-*.conf /run/net6-*.conf; do
|
||||
if [ -e "$conf" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2039,SC2086,SC3043
|
||||
run_tailscale()
|
||||
{
|
||||
@@ -42,7 +54,19 @@ run_tailscale()
|
||||
|
||||
# FIXME: This races with dropbear-initramfs bringing up the network
|
||||
# asynchronously
|
||||
[ "$BOOT" = nfs ] || configure_networking
|
||||
if [ "$BOOT" != nfs ]; then
|
||||
# Keep trying to bring up the network until it's up
|
||||
# or the boot process continues toward finish.
|
||||
while true; do
|
||||
# "." builtin (in dash) exits on error. Run configure_networking
|
||||
# in a subshell and wait for it.
|
||||
configure_networking &
|
||||
wait $!
|
||||
if ! [ -e "$PIDFILE" ] || network_up; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# A little race-y to start the client before the daemon, but the client
|
||||
# will attempt to connect to the socket for a while.
|
||||
@@ -59,6 +83,6 @@ run_tailscale()
|
||||
|
||||
modprobe tun
|
||||
run_tailscale &
|
||||
echo $! > /run/tailscale.pid
|
||||
echo $! > "$PIDFILE"
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user