1
0
mirror of synced 2026-05-01 06:08:37 +00:00
Files
xen-tools.xen-tools/etc/hook.d/50-setup-hostname
steve dcee5ac308 2006-05-24 19:28:29 by steve
More updates.
2006-05-24 19:28:29 +00:00

45 lines
865 B
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 "${ip} ${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
echo "${ip} ${hostname}" >> /etc/hosts
fi