1
0
mirror of synced 2026-04-30 21:58:36 +00:00
Files
xen-tools.xen-tools/etc/hook.d/50-setup-hostname
steve f881ee1025 2006-06-07 09:10:27 by steve
Fixup to change the ip from ${ip} -> ${ip1}
2006-06-07 09:10:27 +00:00

67 lines
1.3 KiB
Bash
Executable File

#!/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
dist=$2
#
# This script doesn't do anything different on a per-distribution basis
#
echo ${hostname} > ${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
fi
#
# Allow the host system to know the IP address of our new guest.
#
if [[ -z "${dhcp}" ]]; then
if ( grep ${hostname} /etc/hosts > /dev/null ) ; then
# Host already has IP address for the given host.
:
else
echo "${ip1} ${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 ] ;
if [ -e /var/run/dnsmasq.pid ]; then
kill -HUP `cat /var/run/dnsmasq.pid`
fi
fi
fi
fi