Skip to content
Snippets Groups Projects
Commit 5fb22581 authored by Thomas Woerner's avatar Thomas Woerner
Browse files

infra/image/shcontainer: Add host entry in container_start

The management of hosts is deactivated in container_create to not copy
all entries from the host system to the container. The host entry is now
created in container_start to fix IPA deployment using this container.
parent 0d9b1643
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,17 @@ container_start() { ...@@ -55,6 +55,17 @@ container_start() {
log info "= Starting ${name} =" log info "= Starting ${name} ="
podman start "${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 # Ensure /etc/shadow is readable
podman exec "${name}" bash -c "chmod u+r /etc/shadow" podman exec "${name}" bash -c "chmod u+r /etc/shadow"
echo echo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment