57 lines
1.5 KiB
Bash
Executable File
57 lines
1.5 KiB
Bash
Executable File
#!/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
|
|
[[ "$BLOCK_BUTTON" == 3 ]] && firefox
|
|
|
|
# get LONG status
|
|
[[ "$BLOCK_BUTTON" == 1 || "$BLOCK_BUTTON" =~ "long" ]] && LONG=true || LONG=false
|
|
|
|
# get interface
|
|
if [[ -n "$BLOCK_INSTANCE" ]]; then
|
|
IF="${BLOCK_INSTANCE#long}"
|
|
else
|
|
IF=$(ip route | awk '/^default/ { print $5 ; exit }')
|
|
fi
|
|
|
|
# check if network interface is available
|
|
if [[ "$IF" == "" || ! -d "/sys/class/net/$IF" ]]; then
|
|
[[ "$LONG" ]] && echo "No network interface found\nn/a\n\n" || echo "n/a\nn/a\n\n"
|
|
exit 33
|
|
fi
|
|
|
|
# get interface information
|
|
LAN=$(ip addr | grep -E "$IF")
|
|
|
|
# check if interface is up
|
|
if [[ "$LAN" =~ " UP " ]]; then
|
|
|
|
# check if interface is connected
|
|
if [[ "$LAN" =~ \<.*UP.*\> ]]; then
|
|
|
|
WAN_IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
|
|
# check if internet connection is established
|
|
if [[ "$?" -eq 0 && $WAN_IP != "" ]]; then
|
|
[[ $LONG ]] && echo $WAN_IP || echo up
|
|
else
|
|
echo "lan"
|
|
fi
|
|
fi
|
|
else
|
|
[[ "$LONG" ]] && echo "$IF: off\noff\n\n" || echo "off\noff\n\n"
|
|
fi
|