Kickstart post install config

Steve Phillips steve at focb.co.nz
Tue Aug 10 00:53:05 UTC 2004


On Mon, 9 Aug 2004, Anoop Bhat wrote:
>
> Steve,
>
> I replied regarding setting up a hardlink/softlink to the file in
> /mnt/sysimage but that won't work because I won't be able to
> softlink/hardlink /tmp/ks-script while its running.
>
> so the alternative would be to setup another script and have that other
> script excute in chrooted env and then exit and return back to the
> non-chrooted post install system.
>
> what do you think?

I found when using the kickstart stuff that the %post side of things was 
already done within a chroot environment.

A copy of my %post script was as follows

In this case I had a "changes" tgz file that I uncompressed from the cdrom 
into the chroot environment, I then used these files to customise my 
installation

(at this point as well the /dev directory did not appear to contain a lot 
of the standard devices, probably due to makedev init script not being 
run)

Please note - this was a very rushed quick and dirty script - it worked 
but if i had time to do things differently there would be quite a bit of 
cleaning up I'd do :-)


%post

# it appears we are in a chroot jail

# make cdrom device (hda)

mknod /tmp/cdrom b 3 0
mknod /dev/sda b 8 0
mkdir /mnt/cdrom

# mount it

mount /tmp/cdrom /mnt/cdrom

# uncompress the changes tgz onto the hard drive

cd /

echo "* Uncompressing TGZ file"
tar -zxf /mnt/cdrom/changes.tgz

echo "* Modifying system.."

# update the fwman and backup directorys

echo "- Copying fwman and backup directories.."
cp -a /changes/fwman/* /fwman/
cp -a /changes/backup  /backup

# update system files as needed

echo "- modifying /etc.."
cat /changes/etc/passwd >> /etc/passwd
cat /changes/etc/shadow >> /etc/shadow
cat /changes/etc/group >> /etc/group
cat /changes/etc/crontab >> /etc/crontab

cp -f /changes/etc/iptables.boot /etc/iptables.boot
cp -f /changes/etc/iptables.boot /etc/iptables.conf
cp -f /changes/etc/hosts /etc/hosts
cp -f /changes/etc/resolv.conf /etc/resolv.conf
cp -f /changes/etc/services /etc/services
cp -f /changes/etc/fstab /etc/fstab
cp -f /changes/etc/sysconfig/rhn/up2date /etc/sysconfig/rhn/up2date
cp -f /changes/etc/sysconfig/network-scripts/route-eth5 /etc/sysconfig/network-scripts/
cp -f /changes/etc/xinetd.d/autoton /etc/xinetd.d/autoton
cp -f /changes/etc/init.d/sme_firewall /etc/init.d/sme_firewall
cp -f /changes/etc/init.d/sme_netconfig /etc/init.d/sme_netconfig
cp -f /changes/etc/rc.sysinit /etc/rc.sysinit

# Setup symlinks for the iptables stuff
ln -s /sbin/iptables /usr/local/sbin/iptables
ln -s /sbin/iptables-save /usr/local/sbin/iptables-save
ln -s /sbin/iptables-restore /usr/local/sbin/iptables-restore

# Create home directories

USERID=1000
GROUPID=1000

for each in user1 user2 user3 user4; do
         mkdir /home/$each
         cp -a /etc/skel/.??* /home/$each
         chown -R $USERID:$GROUPID /home/$each
         USERID=$(($USERID+1))
         GROUPID=$(($GROUPID+1))
done

# setup the firstboot script

echo "- setting up first-boot.."
cp -f /changes/first-boot /etc/rc.d/rc3.d/S05first-boot
cp -f /changes/check-cd /etc/rc.d/rc3.d/S09check-cd
cp -f /changes/etc/rc.d/rc.local /etc/rc.d/rc.local

# eject CDROM
echo "- cleaning up.."

umount /mnt/cdrom

# delete the /tmp/cdrom file
rm -f /tmp/cdrom

# For some reason /dev/cdrom isn't being created - make it now
ln -s /dev/hda /dev/cdrom

# setup grub
rm -rf /boot
mkdir /boot
cp -a /changes/boot/* /boot/
sleep 1
grub-install /dev/sda






More information about the redhat-list mailing list