#!/usr/bin/env bash
echo "Network information:"
echo "===================="
LISTSERVICES="networksetup -listnetworkserviceorder"
AIRPORTI="airport -I"
# Ermitteln ob WLAN aktiv
WLANACTIVE=1
($AIRPORTI|grep -q 'AirPort: Off') && WLANACTIVE=0
# Entsprechend 'schöne' Ausgaben erzeugen
if (( WLANACTIVE )); then
while read line; do
case "$line" in
agrCtlRSSI:*)
QUALITY=${line##*: }
;;
lastTxRate:*)
SPEED=${line##*: }
;;
SSID:*)
SSID=${line##*: }
;;
channel:*)
CHANNEL=${line##*: }
;;
*)
;;
esac
done < <($AIRPORTI)
if [ "$SSID" = "SSID:" ]; then
echo "WIFI: enabled (not connected)"
else
echo "WIFI: enabled"
echo "Network: $SSID"
echo "Speed: $SPEED Mbit/s"
echo "Quality: $QUALITY
dB"
fi
else
echo "WIFI: disabled"
fi
# make some lines
echo
# Geräte ermitteln
# ... unnötige Teile herausschneiden.
while read device; do
#empty line / placeholder
echo
IFACE=${device%%:*}
NAME=${device##*:}
case "$IFACE" in
en*)
echo "Interface: $NAME"
echo "========================"
ifconfig $IFACE
# TODO: hier muß erweitert werden
;;
Bluetooth-Modem*)
#echo $NAME
;;
*)
;;
esac
done < <($LISTSERVICES|sed -E -e '/Device:/!d; s/^\(Hardware Port: *(.*), *Device: *(.*)\)$/\2:\1/'|sort)