Skip to content

Commit 127c44a

Browse files
committed
Use get_current_ip in update_motd_ip; BusyBox hostname has no -I
An Alpine update aborted after reporting success: hostname: unrecognized option: I in line 86: exit code 1: while executing command awk '{print $1}' update_motd_ip built the profile file's IP with `hostname -I | awk '{print $1}'`, which is GNU-specific. On Alpine hostname is BusyBox, the option does not exist, and under pipefail the failing first stage took the whole update with it. The same function already resolves the MOTD line's address with get_current_ip a few lines above, and that helper has an explicit Alpine branch using `ip addr`. So this is not a new capability, just the second site using the first one's answer. Surfaced because start() now reaches update_motd_ip at all: it had been dead code behind every ct script's own exit, so this line had never run anywhere. Checked the rest of the update path for the same class of problem. ssh_check's `hostname -I` and arch_check's `dpkg --print-architecture` are host-side and not reached. check_container_resources uses `free -m`, which BusyBox 1.37 supports -- the reported run got past it. run_addon_updates only globs /usr/local/bin. Verified with a BusyBox-shaped hostname stub that fails on -I: the function completes under set -euo pipefail and writes the correct address.
1 parent a512bca commit 127c44a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ui/validate.func

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ update_motd_ip() {
8383
# Get current values
8484
local current_os="$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"') - Version: $(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"')"
8585
local current_hostname="$(hostname)"
86-
local current_ip="$(hostname -I | awk '{print $1}')"
86+
# get_current_ip, not `hostname -I`: BusyBox's hostname has no -I, so on
87+
# Alpine this aborted the update with "unrecognized option: I". The helper
88+
# a few lines above already handles that and is used for the MOTD line.
89+
local current_ip="$(get_current_ip)"
8790

8891
# Update only if values actually changed
8992
if ! grep -q "OS:.*$current_os" "$profile_file" 2>/dev/null; then

0 commit comments

Comments
 (0)