#!/bin/sh -fu

. install2-init-functions
. $destdir/etc/sysconfig/network

if [ "$HOSTNAME" = 'localhost.localdomain' ] ; then  
proc=$(chroot $destdir bash -c 'hal-find-by-capability --capability processor | head -n 1 | xargs -r -i hal-get-property --udi {} --key info.product | cut -d" " -f 2-3| sed s/\(.*\)//' | tr ' _/' '---')
mactail=$(chroot $destdir  bash -c 'hal-find-by-capability --capability net.80203 | head -n 1 | xargs -r -i hal-get-property --udi {} --key net.address | cut -d: -f4-6 | tr -d ":"')
[ -n "$mactail" ] && [ -n "$proc" ]  && mactail=-$mactail

hostname="comp-$proc$mactail"
echo $hostname > $destdir/etc/HOSTNAME
subst "s/HOSTNAME=localhost.localdomain/HOSTNAME=$hostname/" $destdir/etc/sysconfig/network
fi
:
