1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

Remove unneeded external IP address check

This commit is contained in:
Joe Groocock 2016-04-17 23:33:20 +01:00
parent 7c26b1b885
commit b60dfcc6a7

View File

@ -19,9 +19,9 @@
# Use the provided interface, otherwise the device used for the default route. # Use the provided interface, otherwise the device used for the default route.
if [[ -n $BLOCK_INSTANCE ]]; then if [[ -n $BLOCK_INSTANCE ]]; then
IF=$BLOCK_INSTANCE IF=$BLOCK_INSTANCE
else else
IF=$(ip route | awk '/^default/ { print $5 ; exit }') IF=$(ip route | awk '/^default/ { print $5 ; exit }')
fi fi
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -33,30 +33,24 @@ fi
#------------------------------------------------------------------------ #------------------------------------------------------------------------
if [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then if [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then
echo down # full text echo down # full text
echo down # short text echo down # short text
echo \#FF0000 # color echo \#FF0000 # color
exit exit
fi fi
case $1 in case $1 in
-4) -4) AF=inet ;;
AF=inet ;; -6) AF=inet6 ;;
-6) *) AF=inet6? ;;
AF=inet6 ;;
*)
AF=inet6? ;;
esac esac
# if no interface is found, use the first device with a global scope # if no interface is found, use the first device with a global scope
LOCIP=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit") LOCIP=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit")
EXTIP=$(curl -s http://whatismijnip.nl |cut -d " " -f 5)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
case $BLOCK_BUTTON in case $BLOCK_BUTTON in
1) echo "$EXTIP";; 1) echo $(curl -s http://whatismijnip.nl | cut -d " " -f 5);;
# 2) echo -n "$LOCIP" | xclip -q -se c ;; *) echo "$LOCIP";;
# 3) echo -n "$EXTIP" | xclip -q -se c ;;
*) echo "$LOCIP";;
esac esac