enhance ip module: bufgixes and wording

This commit is contained in:
koksnuss 2018-06-07 08:30:25 +02:00
parent cb0e767bd9
commit 9e4e98889e

View File

@ -1,25 +1,13 @@
#!/bin/bash #!/bin/bash
# kurzinformation:
# ist ein Netzwerkadapter vorhanden?
# JA
# ist eine netzwerkverbindung vorhanden?
# JA
# ist eine Internetverbindung vorhanden?
# JA
# *up/down* *interface: Internet IP-ADRESSE, up/down* green
# NEIN
# *up/down* *interface: Intranet IP-ADRESSE, up/down* orange
# NEIN
# *off* *interface: off*
# NEIN
# *n/a* *network interface not available*
# start firefox # start firefox
[[ "$BLOCK_BUTTON" == 3 ]] && firefox [[ "$BLOCK_BUTTON" == 3 ]] && firefox
# get LONG status # get LONG status
[[ "$BLOCK_BUTTON" == 1 || "$BLOCK_INSTANCE" =~ "long" ]] && LONG=true || LONG=false if [[ "$BLOCK_BUTTON" == 1 ]]; then
[[ "$LONG" = true ]] && LONG=false || LONG=true
fi
[[ "$BLOCK_INSTANCE" =~ "long" ]] && LONG=true
# get interface # get interface
if [[ -n "$BLOCK_INSTANCE" ]]; then if [[ -n "$BLOCK_INSTANCE" ]]; then
@ -28,9 +16,15 @@ else
IF=$(ip route | awk '/^default/ { print $5 ; exit }') IF=$(ip route | awk '/^default/ { print $5 ; exit }')
fi fi
# check if network interface is available # check if network interface is empty
if [[ "$IF" == "" || ! -d "/sys/class/net/$IF" ]]; then if [[ -z "$IF" ]]; then
[[ "$LONG" ]] && echo "No network" || echo "n/a" [[ "$LONG" = true ]] && echo "No interface" || echo "n/a"
exit 33
fi
# check if the network interface exists
if [[ ! -d "/sys/class/net/$IF" ]]; then
[[ "$LONG" = true ]] && echo "No interface" || echo "n/a"
exit 33 exit 33
fi fi
@ -46,11 +40,19 @@ if [[ "$LAN" =~ " UP " ]]; then
WAN_IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//') WAN_IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
# check if internet connection is established # check if internet connection is established
if [[ "$?" -eq 0 && $WAN_IP != "" ]]; then if [[ "$?" -eq 0 && $WAN_IP != "" ]]; then
[[ $LONG ]] && echo $WAN_IP || echo up if [[ "$LONG" = true ]]; then
echo $WAN_IP
echo $WAN_IP
echo "#04B431"
else
echo wan
echo wan
echo "#04B431"
fi
else else
echo "lan" echo "lan"
fi fi
fi fi
else else
[[ "$LONG" ]] && echo "$IF: off\noff\n\n" || echo "off\noff\n\n" [[ "$LONG" = true ]] && echo "$IF: off" || echo "off"
fi fi