diff --git a/infra/image/shcontainer b/infra/image/shcontainer index 3b6c49689fe9f3b2be93dbf76b88dcd6e39dd2cc..6e387cde57e7c2c80ae8659d2613481a9572329d 100644 --- a/infra/image/shcontainer +++ b/infra/image/shcontainer @@ -55,6 +55,17 @@ container_start() { log info "= Starting ${name} =" podman start "${name}" + # Add host entry to /etc/hosts + ip=$(podman inspect "${name}" --format "{{.NetworkSettings.IPAddress}}") + hostname=$(podman inspect "${name}" --format "{{.Config.Hostname}}") + if [ -n "${ip}" ] && [ -n "${hostname}" ]; then + cmd=$(cat <<EOF +sed -i -e "/[ \t]${hostname}/d" /etc/hosts +echo -e "$ip\t${hostname} ${hostname%%.*}" >> /etc/hosts +EOF + ) + podman exec "${name}" bash -c "$cmd" + fi # Ensure /etc/shadow is readable podman exec "${name}" bash -c "chmod u+r /etc/shadow" echo