@dholtz-docbox
Looking at my old scripts ( i am not using at moment) i found one that changes linux hostname and swap uuid:
/images/postdownloadscripts/fog.hosts
#the file contents
-----------------------
#/bin/sh
. /usr/share/fog/lib/funcs.sh;
partition=`lsblk -o KNAME,FSTYPE,LABEL /dev/sda? | grep -v -E "swap|KNAME" | awk '{print $1}'`
mountpoint="/test"
linuxhostname="$mountpoint/etc/hostname"
comandomount="mount"
swappart=`blkid | grep swap | awk -F"\"" '{print $2}'`
dots "Creating mount point"
mkdir -p $mountpoint 2>/dev/null && echo "OK" || echo "Error"
for i in $partition
do
tipopart=`lsblk -o FSTYPE /dev/$i | grep -v FSTYPE`
if [ $tipopart = "ext4" ]
then
comandomount="mount -t $tipopart"
fi
dots "Mounting Partition /dev/$i"
$comandomount /dev/$i $mountpoint && status="OK" || status="Error"
if [ $status = "OK" ]
then
echo "OK"
if [ -e $linuxhostname ]; then
dots "Changing hostname on Linux"
echo $hostname > $linuxhostname && echo "OK" || echo "Error"
fi
dots "Changing swap UUID inside fstab file"
fstabpart=`cat $mountpoint/etc/fstab | grep swap | grep UUID | cut -d"=" -f2| awk '{print $1}'`
sed -i "s/$fstabpart/$swappart/g" $mountpoint/etc/fstab && echo "OK" || echo "Error"
umount $mountpoint
else
echo "Error mounting partition $partition"
fi
done
don’t forget to put directive calling this script inside /images/postdownloadscripts/fog.postdownload
It was used many times and works, but i don’t know if this is the final version put at production.
some ideas.