|
|
@ -448,6 +448,30 @@ prompt_public_ip() {
|
|
|
|
|
|
|
|
|
|
|
|
# grab a fresh IP if needed
|
|
|
|
# grab a fresh IP if needed
|
|
|
|
if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then
|
|
|
|
if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then
|
|
|
|
|
|
|
|
# if method specified, don't use fallback methods
|
|
|
|
|
|
|
|
if [[ -n $POWERLEVEL9K_PUBLIC_IP_METHOD ]] && [[ $POWERLEVEL9K_PUBLIC_IP_METHOD =~ 'wget|curl|dig' ]]; then
|
|
|
|
|
|
|
|
local method=$POWERLEVEL9K_PUBLIC_IP_METHOD
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $method ]]; then
|
|
|
|
|
|
|
|
case $method in
|
|
|
|
|
|
|
|
'dig')
|
|
|
|
|
|
|
|
if type -p dig >/dev/null; then
|
|
|
|
|
|
|
|
fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)"
|
|
|
|
|
|
|
|
[[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
'curl')
|
|
|
|
|
|
|
|
if [[ -z "$fresh_ip" ]] && type -p curl >/dev/null; then
|
|
|
|
|
|
|
|
fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
'wget')
|
|
|
|
|
|
|
|
if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then
|
|
|
|
|
|
|
|
fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
else
|
|
|
|
if type -p dig >/dev/null; then
|
|
|
|
if type -p dig >/dev/null; then
|
|
|
|
fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)"
|
|
|
|
fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)"
|
|
|
|
[[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip
|
|
|
|
[[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip
|
|
|
@ -460,6 +484,7 @@ prompt_public_ip() {
|
|
|
|
if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then
|
|
|
|
if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then
|
|
|
|
fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)"
|
|
|
|
fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
[[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE
|
|
|
|
[[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|