On Sat, Feb 19, 2011 at 04:09, Patrick Lists <ks-list@xxxxxxxxxxxxxxxxx> wrote: > You could test for the number of interfaces. Since I'm a total n00b in this > area hopefully the experienced folks who monitor this list will have a good > laugh at my "scripting" and come up with something better that actually > works :) > > Here's how I would try to solve it. Totally untested, use at own risk. Mind > the linewrap. It's all one line. My box has lo, br0, eth0 and virbr0 so the > script should give a total of 4 interfaces. > > $ ifconfig -a | grep -vE 'inet|UP|RX|TX|collisions|Interrupt' | awk 'BEGIN > {no_of_interfaces=0} /^[a-z]/ {print $1}' | awk 'END {no_of_interfaces=NR; > print "Number of interfaces: " no_of_interfaces}' > > Number of interfaces: 4 (correct so apparently this works) > > You could add this to the %pre section in your kickstart file: > > %pre > NO_OF_INTERFACES=`ifconfig -a | grep -vE > 'inet|UP|RX|TX|collisions|Interrupt' | awk 'BEGIN {no_of_interfaces=0} > /^[a-z]/ {print $1}' | awk 'END {no_of_interfaces=NR; print > no_of_interfaces}'` > echo "INTERFACE_COUNT=$NO_OF_INTERFACES" > /tmp/interface_count.txt > > Then in the %post section test if the value is greater than or equal to 2 in > which case you configure both interfaces. Or else configure one interface: > > %post > # first get the nr of interfaces from the interface_count.txt file > # afaik usually at the top of %post > source /tmp/interface_count.txt > > # test the value. not sure if I need to quote INTERFACES and 2 > if [ "\$INTERFACE_COUNT" -ge "2" ]; then > # configure 2 nics > network --device eth0 --bootproto dhcp > network --device eth1 --onboot no --bootproto dhcp > else > # configure 1 nic > network --device eth0 --bootproto dhcp > fi > > Since I don't know awk I got the syntax from the excellent n00b-friendly awk > tutorial at > http://bashshell.net/stream-filtering-utilities/exercise-1-learning-awk-basics/ > > Hope this helps. > > Regards, > Patrick Nice Idea Patrick, It just a but, it will include WLAN, Local loopback as well and not only ethX interfaces. So just change the grep to: ifconfig -a | grep -E 'eth' | awk 'BEGIN {no_of_interfaces=0} /^[a-z]/ {print $1}' | awk 'END {no_of_interfaces=NR; print "Number of interfaces: " no_of_interfaces}' will just count the eth interfaces. Kind regards Mats _______________________________________________ Kickstart-list mailing list Kickstart-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/kickstart-list