core/larch/buildscripts/larch-hosts
2011-03-20 09:06:57 +00:00

32 lines
792 B
Bash
Executable File

#!/bin/bash
#
# larch-hosts - Add hostname to /etc/hosts file (in overlay)
#
#2011.01.26
# $1: path to system to be larchified ("" if running system)
# $2: path to temporary overlay directory (where the overlay is being built)
INSTLDIR="$1"
OVERLAYDIR="$2"
hosts="${OVERLAYDIR}/etc/hosts"
# If a link is used for the hosts file, assume no processing is needed
[ -L ${hosts} ] && exit 0
if ! [ -f ${hosts} ]; then
# If not provided in the profile rootoverlay, get it from the installation
cp ${INSTLDIR}/etc/hosts ${OVERLAYDIR}/etc
fi
HOSTNAME="UNKNOWN"
if [ -f ${OVERLAYDIR}/etc/rc.conf ]; then
. ${OVERLAYDIR}/etc/rc.conf
else
. ${INSTLDIR}/etc/rc.conf
fi
lh="127.0.0.1 localhost.localdomain localhost "
sed -i "s|^127\.0\.0\.1.*|${lh}${HOSTNAME}|" ${hosts}