%pre --interpreter /usr/bin/python
import os, sys
sys.path.append('/usr/lib/anaconda')
import isys
# get a sorted list of drives
drives = isys.hardDriveDict().keys()
drives.sort()
# write the include file to /tmp/kspart, drives[0] is the first drive,
# drives[1] is the second, etc. To get the filet to be used, put
# '%include /tmp/partitions' in your kickstart configuration.
print "Writing partition details"
f = open("/tmp/partitions", "w")
f.write("part /boot --size 400 --ondisk %s\n" % drives[0])
f.write("part / --size 6144 --ondisk %s\n" % drives[0])
f.write("part swap --size 2048 --ondisk %s\n" % drives[0])
f.write("part /var --size 3072 --ondisk %s\n" % drives[0])
f.write("part /home --size 2048 --ondisk %s\n" % drives[0])
f.write("part /tmp --size 4096 --ondisk %s\n" % drives[0])
f.write("part /data --size 6144 --ondisk %s\n" % drives[0])
f.close()
So, with this, I'd like to do different things, according to the
number of drives, with an if/elseif loop (is there a better way?)
This is what I've tried:
if [ drives[] == "5" ] ; then
f = open("/tmp/num_drives","w")
f.write("5")
f.close()
elif [ drives[] == "4" ] ; then
f = open("/tmp/num_drives","w")
f.write("4")
f.close()
elif [ drives[] == "3" ] ; then
f = open("/tmp/num_drives","w")
f.write("3")
f.close()
<--snip-->
but it fails. Can someone please help with this?