This repository has been archived on 2019-02-28. You can view files and clone it, but cannot push or open issues or pull requests.

40 lines
1.6 KiB
Bash

[[ "$BLOCK_BUTTON" == 2 ]] && firefox
# 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 exists or is empty
if [[ -z "$IF" || ! -d "/sys/class/net/$IF" ]]; then
printf "$IF not found\nn/a\n"
exit 33
fi
LAN=$(ip addr | grep -E "$IF")
# check if interface is up
if [[ $LAN =~ [[:space:]]UP[[:space:]] ]]; 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_TEXT="WAN $WAN_IP"
SHORT_TEXT="WAN"
else
# LAN_IP6=$(echo $LAN | grep -oE "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"
LONG_TEXT="LAN #TODO"
SHORT_TEXT="LAN"
fi #TODO: message
fi #TODO: message
else
LONG_TEXT="$IF off"
SHORT_TEXT="off"
fi
LOAD=false