How to detect the number of network adapters installed from kickstart file for network config?

Patrick Lists ks-list at puzzled.xs4all.nl
Sat Feb 19 12:43:07 UTC 2011


On 02/19/2011 04:09 AM, Patrick Lists wrote:
[snip]
> 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)

Rereading your question and the script above it greps all interfaces 
while I think you only need the eth interfaces. If that is the case 
change /^[a-z]/ to /^eth/

$ ifconfig -a | grep -vE 'inet|UP|RX|TX|collisions|Interrupt' | awk 
'BEGIN {no_of_interfaces=0} /^eth/ {print $1}' | awk 'END 
{no_of_interfaces=NR; print "Number of interfaces: " no_of_interfaces}'

Number of interfaces: 1

Regards,
Patrick




More information about the Kickstart-list mailing list