From 49db07bcf83f05a8114df8421322f95002f3a7a4 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Tue, 5 Jun 2012 18:12:41 +0200 Subject: [PATCH] Merge all centos/fedora 50-setup-hostname into common/50-setup-hostname-rpm Rename previous common/50-setup-hostname to common/50-setup-hostname-deb; adjust all links --- hooks/centos-4/50-setup-hostname | 123 +----------------- hooks/centos-5/50-setup-hostname | 120 +---------------- ...0-setup-hostname => 50-setup-hostname-deb} | 0 hooks/common/50-setup-hostname-rpm | 122 +++++++++++++++++ hooks/dapper/50-setup-hostname | 2 +- hooks/debian/50-setup-hostname | 2 +- hooks/edgy/50-setup-hostname | 2 +- hooks/fedora-core-6/50-setup-hostname | 121 +---------------- hooks/intrepid/50-setup-hostname | 2 +- hooks/karmic/50-setup-hostname | 2 +- 10 files changed, 130 insertions(+), 366 deletions(-) mode change 100755 => 120000 hooks/centos-4/50-setup-hostname mode change 100755 => 120000 hooks/centos-5/50-setup-hostname rename hooks/common/{50-setup-hostname => 50-setup-hostname-deb} (100%) create mode 100755 hooks/common/50-setup-hostname-rpm mode change 100755 => 120000 hooks/fedora-core-6/50-setup-hostname diff --git a/hooks/centos-4/50-setup-hostname b/hooks/centos-4/50-setup-hostname deleted file mode 100755 index 0d60567..0000000 --- a/hooks/centos-4/50-setup-hostname +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/sh -# -# This script places the new systems hostname into a couple of files within -# the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Setup the mailname + hostname files. -# -echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname -echo ${hostname} > ${prefix}/etc/mailname - - -# -# Fixup the /etc/hosts file upon the new image for -# machines with static IPs -# -if [ -z "${dhcp}" ]; then - - # Non-IPv6 stuff. - grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts - - # New entry. - echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts - echo " " >> ${prefix}/etc/hosts - - # IPv6 stuff. - grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts - -else - - # - # Stub /etc/hosts for DHCP clients. - # - cat >> ${prefix}/etc/hosts < /dev/null ) ; then - - logMessage Host already has IP address for the host ${hostname}. - - else - - # - # Short host name. - # - name=`echo ${hostname} | awk -F. '{print $1}'` - - if [ -z "${nohosts}" ]; then - - logMessage Adding ${hostname} and ${name} to /etc/hosts on the host - - echo "${ip1} ${hostname} ${name}" >> /etc/hosts - - - - # - # If we've updated the /etc/hosts file on the host machine - # and there is an installation of dnsmasq installed then - # reload it. - # - # This will let the local LAN clients lookup the new address. - # - if [ -x /usr/sbin/dnsmasq ] ; then - if [ -e /var/run/dnsmasq.pid ]; then - - logMessage Allowing DNSMasq to restart. - kill -s HUP `cat /var/run/dnsmasq.pid` - fi - fi - fi - fi -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-4/50-setup-hostname b/hooks/centos-4/50-setup-hostname new file mode 120000 index 0000000..8680ec6 --- /dev/null +++ b/hooks/centos-4/50-setup-hostname @@ -0,0 +1 @@ +../common/50-setup-hostname-rpm \ No newline at end of file diff --git a/hooks/centos-5/50-setup-hostname b/hooks/centos-5/50-setup-hostname deleted file mode 100755 index 2ea9a29..0000000 --- a/hooks/centos-5/50-setup-hostname +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh -# -# This script places the new systems hostname into a couple of files within -# the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Setup the mailname + hostname files. -# -echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname -echo ${hostname} > ${prefix}/etc/mailname - - -# -# Fixup the /etc/hosts file upon the new image for -# machines with static IPs -# -if [ -z "${dhcp}" ]; then - - # Non-IPv6 stuff. - grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts - - # New entry. - echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts - echo " " >> ${prefix}/etc/hosts - - # IPv6 stuff. - grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts - -else - - # - # Stub /etc/hosts for DHCP clients. - # - cat >> ${prefix}/etc/hosts < /dev/null ) ; then - - logMessage Host already has IP address for the host ${hostname}. - - else - - # - # Short host name. - # - name=`echo ${hostname} | awk -F. '{print $1}'` - - if [ -z "${nohosts}" ]; then - - logMessage Adding ${hostname} and ${name} to /etc/hosts on the host - echo "${ip1} ${hostname} ${name}" >> /etc/hosts - - # - # If we've updated the /etc/hosts file on the host machine - # and there is an installation of dnsmasq installed then - # reload it. - # - # This will let the local LAN clients lookup the new address. - # - if [ -x /usr/sbin/dnsmasq ] ; then - if [ -e /var/run/dnsmasq.pid ]; then - - logMessage Allowing DNSMasq to restart. - kill -s HUP `cat /var/run/dnsmasq.pid` - fi - fi - fi - fi -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/centos-5/50-setup-hostname b/hooks/centos-5/50-setup-hostname new file mode 120000 index 0000000..8680ec6 --- /dev/null +++ b/hooks/centos-5/50-setup-hostname @@ -0,0 +1 @@ +../common/50-setup-hostname-rpm \ No newline at end of file diff --git a/hooks/common/50-setup-hostname b/hooks/common/50-setup-hostname-deb similarity index 100% rename from hooks/common/50-setup-hostname rename to hooks/common/50-setup-hostname-deb diff --git a/hooks/common/50-setup-hostname-rpm b/hooks/common/50-setup-hostname-rpm new file mode 100755 index 0000000..0d60567 --- /dev/null +++ b/hooks/common/50-setup-hostname-rpm @@ -0,0 +1,122 @@ +#!/bin/sh +# +# This script places the new systems hostname into a couple of files within +# the new image. +# +# Steve +# -- +# http://www.steve.org.uk/ + + + +prefix=$1 + + +# +# Source our common functions +# +if [ -e /usr/lib/xen-tools/common.sh ]; then + . /usr/lib/xen-tools/common.sh +else + . ./hooks/common.sh +fi + + +# +# Log our start +# +logMessage Script $0 starting + + +# +# Setup the mailname + hostname files. +# +echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname +echo ${hostname} > ${prefix}/etc/mailname + + +# +# Fixup the /etc/hosts file upon the new image for +# machines with static IPs +# +if [ -z "${dhcp}" ]; then + + # Non-IPv6 stuff. + grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts + + # New entry. + echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts + echo " " >> ${prefix}/etc/hosts + + # IPv6 stuff. + grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts + +else + + # + # Stub /etc/hosts for DHCP clients. + # + cat >> ${prefix}/etc/hosts < /dev/null ) ; then + + logMessage Host already has IP address for the host ${hostname}. + + else + + # + # Short host name. + # + name=`echo ${hostname} | awk -F. '{print $1}'` + + if [ -z "${nohosts}" ]; then + + logMessage Adding ${hostname} and ${name} to /etc/hosts on the host + + echo "${ip1} ${hostname} ${name}" >> /etc/hosts + + + + # + # If we've updated the /etc/hosts file on the host machine + # and there is an installation of dnsmasq installed then + # reload it. + # + # This will let the local LAN clients lookup the new address. + # + if [ -x /usr/sbin/dnsmasq ] ; then + if [ -e /var/run/dnsmasq.pid ]; then + + logMessage Allowing DNSMasq to restart. + kill -s HUP `cat /var/run/dnsmasq.pid` + fi + fi + fi + fi +fi + + +# +# Log our finish +# +logMessage Script $0 finished diff --git a/hooks/dapper/50-setup-hostname b/hooks/dapper/50-setup-hostname index 509952f..961cef8 120000 --- a/hooks/dapper/50-setup-hostname +++ b/hooks/dapper/50-setup-hostname @@ -1 +1 @@ -../common/50-setup-hostname \ No newline at end of file +../common/50-setup-hostname-deb \ No newline at end of file diff --git a/hooks/debian/50-setup-hostname b/hooks/debian/50-setup-hostname index 509952f..961cef8 120000 --- a/hooks/debian/50-setup-hostname +++ b/hooks/debian/50-setup-hostname @@ -1 +1 @@ -../common/50-setup-hostname \ No newline at end of file +../common/50-setup-hostname-deb \ No newline at end of file diff --git a/hooks/edgy/50-setup-hostname b/hooks/edgy/50-setup-hostname index 509952f..961cef8 120000 --- a/hooks/edgy/50-setup-hostname +++ b/hooks/edgy/50-setup-hostname @@ -1 +1 @@ -../common/50-setup-hostname \ No newline at end of file +../common/50-setup-hostname-deb \ No newline at end of file diff --git a/hooks/fedora-core-6/50-setup-hostname b/hooks/fedora-core-6/50-setup-hostname deleted file mode 100755 index 0451180..0000000 --- a/hooks/fedora-core-6/50-setup-hostname +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# -# This script places the new systems hostname into a couple of files within -# the new image. -# -# Steve -# -- -# http://www.steve.org.uk/ - - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Setup the mailname + hostname files. -# -echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname -echo ${hostname} > ${prefix}/etc/mailname - - -# -# Fixup the /etc/hosts file upon the new image for -# machines with static IPs -# -if [ -z "${dhcp}" ]; then - - # Non-IPv6 stuff. - grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts - - # New entry. - echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts - echo " " >> ${prefix}/etc/hosts - - # IPv6 stuff. - grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts - -else - - # - # Stub /etc/hosts for DHCP clients. - # - cat >> ${prefix}/etc/hosts < /dev/null ) ; then - - logMessage Host already has IP address for the host ${hostname}. - - else - - # - # Short host name. - # - name=`echo ${hostname} | awk -F. '{print $1}'` - - if [ -z "${nohosts}" ]; then - - logMessage Adding ${hostname} and ${name} to /etc/hosts on the host - echo "${ip1} ${hostname} ${name}" >> /etc/hosts - - - # - # If we've updated the /etc/hosts file on the host machine - # and there is an installation of dnsmasq installed then - # reload it. - # - # This will let the local LAN clients lookup the new address. - # - if [ -x /usr/sbin/dnsmasq ] ; then - if [ -e /var/run/dnsmasq.pid ]; then - - logMessage Allowing DNSMasq to restart. - kill -s HUP `cat /var/run/dnsmasq.pid` - fi - fi - fi - fi -fi - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/fedora-core-6/50-setup-hostname b/hooks/fedora-core-6/50-setup-hostname new file mode 120000 index 0000000..8680ec6 --- /dev/null +++ b/hooks/fedora-core-6/50-setup-hostname @@ -0,0 +1 @@ +../common/50-setup-hostname-rpm \ No newline at end of file diff --git a/hooks/intrepid/50-setup-hostname b/hooks/intrepid/50-setup-hostname index 509952f..961cef8 120000 --- a/hooks/intrepid/50-setup-hostname +++ b/hooks/intrepid/50-setup-hostname @@ -1 +1 @@ -../common/50-setup-hostname \ No newline at end of file +../common/50-setup-hostname-deb \ No newline at end of file diff --git a/hooks/karmic/50-setup-hostname b/hooks/karmic/50-setup-hostname index 509952f..961cef8 120000 --- a/hooks/karmic/50-setup-hostname +++ b/hooks/karmic/50-setup-hostname @@ -1 +1 @@ -../common/50-setup-hostname \ No newline at end of file +../common/50-setup-hostname-deb \ No newline at end of file