From: Frank Brehm Date: Wed, 28 Mar 2018 09:16:00 +0000 (+0200) Subject: Creating /etc/hosts in bin/postinst X-Git-Tag: 0.1.1~81 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=bdf054de3eb5f853d808d5c9d4182e74969efb55;p=pixelpark%2Fcreate-vmware-tpl.git Creating /etc/hosts in bin/postinst --- 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