/usr/lib/xen-tools/dapper.d/50-setup-hostname is in xen-tools 4.2.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | #!/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
#
# Determine the FQDN and Hostname
#
GUEST_FQDN=${hostname}
GUEST_HOSTNAME=`echo $GUEST_FQDN | awk -F'.' '{print $1}'`
#
# Setup the mailname + hostname files.
#
echo $GUEST_HOSTNAME > ${prefix}/etc/hostname
echo $GUEST_FQDN > ${prefix}/etc/mailname
#
# Fixup the /etc/hosts file upon the new image for
# machines with static IPs
#
if [ -z "${copyhosts}" ]; then
#
# Copy localhost
#
cat > ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
EOF
#
# Make sure our hostname and FQDN is resolvable
#
if [ -z "${dhcp}" ]; then
#
# If dhcp is diabled, FQDN should resolve to our IP
#
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
cat >> ${prefix}/etc/hosts <<EOF
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
EOF
else
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
if [ -z "${dhcp}" ]; then
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
fi
#
# Allow the host system to know the IP address of our new guest.
#
if [ -z "${dhcp}" ]; then
if ( grep $GUEST_FQDN /etc/hosts > /dev/null ) ; then
logMessage Host already has IP address for the host $GUEST_FQDN.
else
if [ -z "${nohosts}" ]; then
logMessage Adding $GUEST_FQDN and $GUEST_HOSTNAME to /etc/hosts on the host
echo "${ip1} $GUEST_FQDN $GUEST_HOSTNAME" >> /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
|