Support OpenBSD
Add OpenBSD support to the scripts Fix sysctl usage for FreeBSD in a couple places
This commit is contained in:
parent
24f6e18ef8
commit
8c02cbc5cc
33 changed files with 283 additions and 19 deletions
|
@ -469,6 +469,27 @@ elif [ "$KERNEL" = "HP-UX" ] ; then
|
|||
echo "$HEADER"
|
||||
echo "$out"
|
||||
fi
|
||||
elif [ "$KERNEL" = "OpenBSD" ] ; then
|
||||
assertHaveCommand ifconfig
|
||||
assertHaveCommand netstat
|
||||
|
||||
CMD_LIST_INTERFACES='ifconfig -a'
|
||||
# shellcheck disable=SC2016
|
||||
CHOOSE_ACTIVE='/^[a-z0-9]+: / {sub(":", "", $1); iface=$1} /media: / {print iface}'
|
||||
UNIQUE='sort -u'
|
||||
# shellcheck disable=SC2016
|
||||
GET_MAC='{$1 == "lladdr" && mac = $2}'
|
||||
# shellcheck disable=SC2016
|
||||
GET_IP='/ (netmask|prefixlen) / {for (i=1; i<=NF; i++) {if ($i == "inet") IPv4 = $(i+1); if ($i == "inet6") IPv6 = $(i+1)}}'
|
||||
out=$($CMD_LIST_INTERFACES | tee "$TEE_DEST" | awk "$CHOOSE_ACTIVE" | $UNIQUE | tee -a "$TEE_DEST")
|
||||
lines=$(echo "$out" | wc -l)
|
||||
if [ "$lines" -gt 0 ]; then
|
||||
echo "$HEADER"
|
||||
fi
|
||||
for iface in $out
|
||||
do
|
||||
echo "$iface $(ifconfig $iface | awk "$GET_MAC $GET_IP END {printf \"%s %s %s\", mac, IPv4, IPv6}") $(echo $(netstat -bnI $iface -w1 | head -n4 | tail -n1) $(netstat -neI $iface -w1 | head -n4 | tail -n1) | awk "{printf \"%s %s %s %s %s\", \$9, \$1, \$6, \$2, \$8}") auto auto"
|
||||
done
|
||||
elif [ "$KERNEL" = "FreeBSD" ] ; then
|
||||
assertHaveCommand ifconfig
|
||||
assertHaveCommand netstat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue