From bdf054de3eb5f853d808d5c9d4182e74969efb55 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 28 Mar 2018 11:16:00 +0200 Subject: [PATCH] Creating /etc/hosts in bin/postinst --- bin/postinst | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/bin/postinst b/bin/postinst index 912b6d5..8ae3883 100644 --- a/bin/postinst +++ b/bin/postinst @@ -7,12 +7,20 @@ COBBLER_URL="http://192.168.88.8" echo "$(date --rfc-3339=seconds): Das ist das Post-Install-Script '$0'." echo +if [[ -z "${hostname}" ]] ; then + hostname="template.pixelpark.com" +fi +IP_ADDRESS_ETH0=$( host "${hostname}" | sed -e 's/.*has address[ ][ ]*//' ) +DOMAIN=$( echo "${hostname}" | cut -d. -f2,3 ) +SIMPLE_HOSTNAME=$( echo "${hostname}" | cut -d. -f1 ) echo echo "Some information:" echo " \$hostname: $hostname" -echo " \$ip_address_ether0: $ip_address_ether0" echo " \$system_name: $system_name" +echo " \$IP_ADDRESS_ETH0: $IP_ADDRESS_ETH0" +echo " \$SIMPLE_HOSTNAME: $SIMPLE_HOSTNAME" +echo " \$DOMAIN: $DOMAIN" #----------------------------------------------------------- log() { @@ -78,11 +86,27 @@ import_ssh_hostkeys() { } +#----------------------------------------------------------- +create_etc_hosts() { + + log "Generating /etc/hosts ..." + + cat <<-EOF >/etc/hosts + # generated by pixelpark install server + + 127.0.0.1 localhost + ${IP_ADDRESS_ETH0} ${hostname} ${SIMPLE_HOSTNAME} + + EOF + +} + #----------------------------------------------------------- main() { create_authkeys import_ssh_hostkeys + create_etc_hosts } @@ -90,4 +114,4 @@ main() { #----------------------------------------------------------- main "$@" -# vim: ts=4 et +# vim: ts=4 et list -- 2.39.5