Tracy,
Great stuff ! I wonder why mine was broken ?!?!?!? Why I gotta get the
broken one ? :o) I'll try it again next time I pine for some automation.
Cheers,
Mike
On Mon, 2008-05-05 at 12:26 -0700, Tracy R Reed wrote:
> Michael J McCafferty wrote:
> > John,
> > I once tried to do all kinds of neat stuff with kickstart. I gave up. I
> > never got the %post scripts to work at all, except the most very basic
> > commands. It was probably me, but I gave up on the automation I wanted
> > to put in %post and wrote a bash script and included in the procedure
> > docs to run the bash script manually. :o(
>
> I've done quite a bit of stuff in %post. Here's mine. Hope this provides
> some clues. Note that some lines got wrapped. Note that the default
> shell in pre or post is just the standard sh or ash or something. In my
> %pre I do fancier things and use:
>
> %pre --interpreter /usr/bin/python
>
> to make python the shell so I can actually program it to do whatever I
> want. I use it to inspect the system and see how many disks we have and
> then write out to /tmp/partinfo one of my standard partition schemes and
> then include that into the kickstart as the partitioning scheme. Here it
> is:
>
>
> #Generated by Tracy Reed [EMAIL PROTECTED]
>
> # Put key <installation number> to register the box with RHN
> # I am just skipping for now
> key --skip
>
> #System language
> lang en_US
>
> #System keyboard
> keyboard us
>
> #Sytem timezone
> timezone America/Los_Angeles
>
> #Root password
> rootpw --iscrypted $1$vKBiVOsC$5jscKpPjii7WXyUNSEBZj/
>
> #Reboot after installation
> reboot
>
> #Use text mode install
> text
>
> #Install OS instead of upgrade
> install
>
> #Use Web installation
> url --url http://10.1.1.1/centos
>
> #System bootloader configuration
> bootloader --location=mbr
>
> #Clear the Master Boot Record
> zerombr
>
> #System authorization infomation
> auth --useshadow --enablemd5
>
> #Network information
> network --bootproto=dhcp --device=eth0
>
> #Firewall configuration
> firewall --disabled
>
> #Do not configure XWindows
> skipx
>
> # Start SE Linux in enforcing mode. Don't turn this off! SE Linux is
> important.
> selinux --enforcing
>
> #Halt the system when the install finishes. Otherwise it might keep
> #installing over the network over and over.
> halt
>
> %include /tmp/partinfo
>
> #Package install information
> %packages
> postfix
> iptraf
> emacs-nox
> sysstat
> subversion
> net-snmp
> @ editors
> @ text-internet
> @ server-cfg
> @ mail-server
> @ development-tools
> @ admin-tools
> @ system-tools
> -sendmail
> -sendmail-cf
> -logwatch
> -postgresql-libs
> -dovecot
> -irda-utils
> -portmap
> -nfs-utils
> -yp-tools
> -ypbind
> -samba-common
> -samba-client
> -spamassassin
> -xorg-x11-Mesa-libGL
> -libglade2
> -pygtk2
> -pygtk2-libglade
> -system-config-nfs
> -system-config-securitylevel
> -system-config-services
> -pango
> -gtk2
> -usermode-gtk
> -bluez-pin
> -xorg-x11-Mesa-libGL
> -tog-pegasus
> -tog-pegasus-devel
> -redhat-lsb
> -java-1.4.2-gcj-compat
> -gcc-java
> -libgcj
> -libgcj-devel
> -pygtk2
> -libwnk
> -GConf2
> -gtk2
> -xorg-x11-Mesa-libGL
> -chkfontpath
> -xorg-x11-xfs
> -xorg-x11-libs
> -emacs
> -bluez-utils
> -bluez-libs
> -bluez-hcidump
> -bluez-fw
> -mysql
> -hesiod
> -hesiod-devel
> -autofs
> -fetchmail
> -ORBit2
> -ckermit
> -freetype
> -fontconfig
> -ttmkfdir
> -wvdial
> -wireless-tools
> -NetworkManager
>
>
> %post
> # Change to virtual terminal 3 so we can watch
> chvt 3
>
> # add comment to /etc/motd
> echo "Kickstart-installed Red Hat Linux `/bin/date`" > /etc/motd
> echo "Interactivate kickstart $Id: ks.cfg.i386 68 2006-08-11 19:18:57Z
> treed $" >> /etc/motd
>
> # Install cfengine
> rpm -ivh http://10.1.1.1/extras/cfengine-2.1.16-2.el4.kb.i386.rpm
>
> # Install python-twisted for my nagios client app
> #rpm -ivh http://10.1.1.1/extras/python-twisted-1.3.0-1.2.el4.rf.x86_64.rpm
> #rpm -ivh
> http://10.1.1.1/extras/python-twisted-docs-1.3.0-1.2.el4.rf.x86_64.rpm
>
> wget http://10.1.1.1/extras/cfagent.conf -O
> /var/cfengine/inputs/cfagent.conf
> wget http://10.1.1.1/extras/cf.groups -O /var/cfengine/inputs/cf.groups
> wget http://10.1.1.1/extras/cfrun.hosts -O /var/cfengine/inputs/cfrun.hosts
> wget http://10.1.1.1/extras/cfservd.conf -O
> /var/cfengine/inputs/cfservd.conf
> wget http://10.1.1.1/extras/update.conf -O /var/cfengine/inputs/update.conf
>
> cat > /etc/rc3.d/S99firstboot << "EOF"
> #
> # This script should do any post-first-boot things and then
> # remove itself so it does not run on the second boot.
> #
>
> /bin/rm /etc/rc3.d/S99firstboot
>
> /usr/sbin/cfagent --no-splay --define sys_startup &
>
> EOF
> /bin/chmod 755 /etc/rc3.d/S99firstboot
>
> /sbin/chkconfig --level 345 cfenvd on
> /sbin/chkconfig --level 345 cfexecd on
> /sbin/chkconfig --level 345 cfservd on
> /etc/init.d/cfexecd start
> /etc/init.d/cfenvd start
>
> # Set system time and write to bios
> /usr/sbin/ntpdate -su pool.ntp.org
> /sbin/hwclock -w
> /sbin/chkconfig --level 345 ntpd on
>
>
> %pre --interpreter /usr/bin/python
>
> import os
> import time
>
>
> raid5="""
> #Partition clearing information, clear hda and hdb
> #This config file assumes a two disk mirrored setup
> clearpart --all --initlabel --drives=sda,sdb,sdc,sdd
>
> #Disk partitioning information
>
> # Create the partitions on the first disk
> # root partition
> part raid.10 --size=4000 --ondisk=sda
> # boot partition
> part raid.11 --size=500 --ondisk=sda
> # swap partition
> part raid.12 --size=2000 --ondisk=sda
> # everything else for the lvm physical volume
> part raid.13 --size=1 --grow --ondisk=sda
>
> # Create the partitions on the second disk
> # root partition
> part raid.20 --size=4000 --ondisk=sdb
> # boot partition
> part raid.21 --size=500 --ondisk=sdb
> # swap partition
> part raid.22 --size=2000 --ondisk=sdb
> # Raid the rest for the LVM physical volume
> part raid.23 --size=1 --grow --ondisk=sdb
>
> # Create the partitions on the third disk
> # root partition
> part raid.30 --size=4000 --ondisk=sdc
> # boot partition
> part raid.31 --size=500 --ondisk=sdc
> # swap partition
> part raid.32 --size=2000 --ondisk=sdc
> # everything else for the lvm physical volume
> part raid.33 --size=1 --grow --ondisk=sdc
>
> # Create the partitions on the fourth disk
> # root partition
> part raid.40 --size=4000 --ondisk=sdd
> # boot partition
> part raid.41 --size=500 --ondisk=sdd
> # swap partition
> part raid.42 --size=2000 --ondisk=sdd
> # everything else for the lvm physical volume
> part raid.43 --size=1 --grow --ondisk=sdd
>
> # Now RAID it all together
> raid / --fstype ext3 --device md0 --level=RAID5 raid.10 raid.20
> raid.30 raid.40
> # /boot is a mirror, not a raid 5. Can't boot from RAID5.
> raid /boot --fstype ext3 --device md1 --level=RAID1 raid.11 raid.21
> raid.31 raid.41
> raid swap --fstype swap --device md2 --level=RAID5 raid.12 raid.22
> raid.32 raid.42
> # Make the rest an LVM physical volume
> raid pv.01 --fstype ext3 --device md3 --level=RAID5 raid.13 raid.23
> raid.33 raid.43
>
> # Now setup the logical volumes
> volgroup sysvg pv.01
> logvol /var --vgname=sysvg --size=2000 --name=var
> logvol /usr --vgname=sysvg --size=2000 --name=usr
> logvol /home --vgname=sysvg --size=2000 --name=home
> # --grow will expand /dj to use all remaining disk space
> #logvol /dj --vgname=sysvg --size=4000 --name=dj
> """
>
> mirror="""
> # This is our disk setup specific to a 2 disk mirrored setup
>
> #Partition clearing information, clear hda and hdb
> #This config file assumes a two disk mirrored setup
> clearpart --all --initlabel --drives=sda,sdb
>
> #Disk partitioning information
>
> # Create the partitions on the first disk
> # root partition
> part raid.10 --size=4000 --ondisk=sda
> # boot partition
> part raid.11 --size=500 --ondisk=sda
> # swap partition
> part raid.12 --size=2000 --ondisk=sda
> # everything else for the lvm physical volume
> part raid.13 --size=1 --grow --ondisk=sda
>
> # Create the partitions on the second disk
> # root partition
> part raid.20 --size=4000 --ondisk=sdb
> # boot partition
> part raid.21 --size=500 --ondisk=sdb
> # swap partition
> part raid.22 --size=2000 --ondisk=sdb
> # Raid the rest for the LVM physical volume
> part raid.23 --size=1 --grow --ondisk=sdb
>
> # Now RAID it all together
> raid / --fstype ext3 --device md0 --level=RAID1 raid.10 raid.20
> raid /boot --fstype ext3 --device md1 --level=RAID1 raid.11 raid.21
> raid swap --fstype swap --device md2 --level=RAID1 raid.12 raid.22
> # Make the rest an LVM physical volume
> raid pv.01 --fstype ext3 --device md3 --level=RAID1 raid.13 raid.23
>
> # Now setup the logical volumes
> volgroup sysvg pv.01
> logvol /var --vgname=sysvg --size=2000 --name=var
> logvol /usr --vgname=sysvg --size=2000 --name=usr
> logvol /home --vgname=sysvg --size=2000 --name=home
> # --grow will expand /dj to use all remaining disk space
> #logvol /dj --vgname=sysvg --size=4000 --name=dj
> """
>
> single="""
> # This is our disk setup specific to a single disk setup which we really
> # hope is a hardware RAID.
>
> #Partition clearing information, clear hda and hdb
> #This config file assumes a two disk mirrored setup
> clearpart --all --initlabel --drives=sda
>
> #Disk partitioning information
>
> # Create the partition
> part / --size=4000 --ondisk=sda
> part pv.0 --size=1 --grow --ondisk=sda
>
>
> # Now setup the logical volumes
> volgroup sysvg pv.0
> logvol /var --vgname=sysvg --size=8000 --name=var
> logvol /usr --vgname=sysvg --size=6000 --name=usr
> logvol /home --vgname=sysvg --size=8000 --name=home
> logvol /tmp --vgname=sysvg --size=4000 --name=tmp
> # --grow will expand /opt to use all remaining disk space
> #logvol /opt --vgname=sysvg --size=4000 --name=opt
>
> """
>
> # Determine how many drives we have
> # list-harddrives gives us a space separated listing of drives and their
> capacities
> fd = os.popen('list-harddrives','r')
> print "list-harddrives output is:"
> disks = 0
>
> for line in fd:
> print line
> disks += 1
>
> print "Detected %d disks" % disks
>
> if disks == 4:
> fd = open("/tmp/partinfo","w")
> fd.write(raid5)
>
> elif disks == 2:
> fd = open("/tmp/partinfo","w")
> fd.write(mirror)
>
> elif disks == 1:
> fd = open("/tmp/partinfo","w")
> fd.write(single)
>
> fd = open("/tmp/partinfo","w")
> fd.write(single)
>
>
> else:
> print "I did not find either 1, 2, or 4 disks! This config is only
> designed to work with a single, 2 (mirrored) or 4 (raid5) disk system!"
> print "You can go to alt-f2 to check out the environment. Going
> into a busy wait. Reboot when you are done."
> while 1:
> time.sleep(60)
>
>
>
--
************************************************************
Michael J. McCafferty
Principal, Security Engineer
M5 Hosting
http://www.m5hosting.com
You can have your own custom Dedicated Server up and running today !
RedHat Enterprise, CentOS, Ubuntu, Debian, OpenBSD, FreeBSD, and more
************************************************************
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list