Skip to content

Commit

Permalink
Merge pull request freeipa#1284 from t-woerner/infra_image_system_ser…
Browse files Browse the repository at this point in the history
…vices_dns_and_kinit

Infra image system services dns and kinit
  • Loading branch information
f-trivino authored Aug 7, 2024
2 parents 88dc4c6 + 36f26bd commit 178cf21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 9 additions & 2 deletions infra/image/system-service/fixipaip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ if [ -z "${PTR}" ] || [ -n "${PTR//[0-9]}" ]; then
echo "ERROR: Failed to get PTR from IPv4 address: '${PTR}'"
exit 1
fi
FORWARDER=$(grep -s -m 1 ^nameserver /etc/resolv.conf.fixnet | cut -d" " -f 2)
if [ -z "${FORWARDER}" ] || [ "${FORWARDER}" == "127.0.0.1" ]; then
FORWARDER="8.8.8.8"
fi

echo "Fix IPA IP:"
echo "Fix IPA:"
echo " HOSTNAME: '${HOSTNAME}'"
echo " IP: '${IP}'"
echo " PTR: '${PTR}'"
echo " FORWARDER: '${FORWARDER}'"

if ! echo "SomeADMINpassword" | kinit -c "${KRB5CCNAME}"
if ! echo "SomeADMINpassword" | kinit -c "${KRB5CCNAME}" admin >/dev/null
then
echo "ERROR: Failed to obtain Kerberos ticket"
exit 1
Expand All @@ -77,6 +82,8 @@ for zone in ${ZONES}; do
fi
done

ipa dnsserver-mod "${HOSTNAME}" --forwarder="${FORWARDER}"

kdestroy -c "${KRB5CCNAME}" -A

exit 0
6 changes: 5 additions & 1 deletion infra/image/system-service/fixnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ else
echo -e "$IP\t${HOSTNAME} ${HOSTNAME%%.*}" >> /etc/hosts
fi

echo "nameserver 127.0.0.1" > /etc/resolv.conf
cp -a /etc/resolv.conf /etc/resolv.conf.fixnet
cat > /etc/resolv.conf <<EOF
search ${HOSTNAME#*.}
nameserver 127.0.0.1
EOF

echo "/etc/hosts:"
cat "/etc/hosts"
Expand Down

0 comments on commit 178cf21

Please sign in to comment.