Merge pull request #1365 from t-woerner/infra_image_start_hosts_safer_removal

infra/image/shcontainer: Safer host removal from /etc/hosts
This commit is contained in:
Rafael Guterres Jeffman
2025-06-04 15:52:02 -03:00
committed by GitHub

View File

@@ -60,7 +60,7 @@ container_start() {
hostname=$(podman inspect "${name}" --format "{{.Config.Hostname}}")
if [ -n "${ip}" ] && [ -n "${hostname}" ]; then
cmd=$(cat <<EOF
sed -i -e "/[ \t]${hostname}/d" /etc/hosts
sed -i -E "/\s+${hostname}(\s|$)/d" /etc/hosts
echo -e "$ip\t${hostname} ${hostname%%.*}" >> /etc/hosts
EOF
)