]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Creating /etc/hosts in bin/postinst
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 28 Mar 2018 09:16:00 +0000 (11:16 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 28 Mar 2018 09:16:00 +0000 (11:16 +0200)
bin/postinst

index 912b6d5c06d607c44a5e5156ef6a622bdd4a6635..8ae38832943dc2f4ce2d37d09bf38e84081ae754 100644 (file)
@@ -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