Rozdiely pre scripts/shell/firewall/ifconfig-parse.sh medzi verziami 1.1 a 1.2
verzia 1.1, 2003/08/07 08:33:42 |
verzia 1.2, 2003/08/08 09:56:53 |
|
|
# All rights reserved. |
# All rights reserved. |
# |
# |
|
|
# $Platon$ |
# $Platon: scripts/shell/firewall/ifconfig-parse.sh,v 1.1 2003/08/07 08:33:42 rajo Exp $ |
|
|
# Parse output from ifconfig: |
# Parse output from ifconfig: |
/sbin/ifconfig | \ |
/sbin/ifconfig | \ |
awk 'BEGIN { interfaces=""; } |
awk 'BEGIN { interfaces=""; } |
/^[a-zA-Z0-9]+/ { |
/^[a-zA-Z0-9]+[ \t]+/ { # Linux |
iface=$1; |
iface=$1; |
interfaces = sprintf("%s %s", interfaces, iface); |
interfaces = sprintf("%s %s", interfaces, iface); |
printf "\nIFACE_%s=\"%s\";\nHWaddr_%s=\"%s\";\nexport IFACE_%s HWaddr_%s\n", |
printf "\nIFACE_%s=\"%s\"; export IFACE_%s;\n", iface, iface, iface; |
$1, $1, $1, $5, $1, $1; |
printf "HWaddr_%s=\"%s\"; export HWaddr_%s;\n", iface, $5, iface; |
} |
} |
/^[ \t]+inet/ { |
/^[ \t]+inet addr:/ { # Linux |
split($0, fields, "[ \t:]+"); |
split($0, fields, "[ \t:]+"); |
printf "IP_%s=\"%s\";\nBcast_%s=\"%s\";\nMask_%s=\"%s\";\n", |
printf "IP_%s=\"%s\"; export IP_%s;\n", iface, fields[4], iface; |
iface, fields[4], iface, fields[6], iface, fields[8]; |
printf "Bcast_%s=\"%s\"; export Bcast_%s;\n", iface, fields[6], iface; |
printf "export IP_%s Bcast_%s Mask_%s\n", |
printf "Mask_%s=\"%s\"; export Mask_%s;\n", iface, fields[8], iface; |
iface, iface, iface; |
|
} |
} |
END { printf "\ninterfaces=\"%s\"\n", interfaces; } |
/^[a-zA-Z0-9]+:/ { # FreeBSD |
|
iface = $1; |
|
sub(":", "", iface); |
|
interfaces = sprintf("%s %s", interfaces, iface); |
|
printf "\nIFACE_%s=\"%s\"; export IFACE_%s;\n", iface, iface, iface; |
|
} |
|
/^[ \t]+inet [0-9]+/ { # FreeBSD |
|
printf "IP_%s=\"%s\"; export IP_%s;\n", iface, $2, iface; |
|
printf "Bcast_%s=\"%s\"; export Bcast_%s;\n", iface, $6, iface; |
|
printf "Mask_%s=\"%s\"; export Mask_%s;\n", iface, $4, iface; |
|
} |
|
/^[ \t]+ether/ { # FreeBSD |
|
printf "HWaddr_%s=\"%s\"; export HWaddr_%s;\n", iface, $2, iface; |
|
} |
|
END { printf "\ninterfaces=\"%s\"; export interfaces;\n", interfaces; } |
' |
' |
|
|
Platon Group <platon@platon.sk> http://platon.sk/
|
|