From 99fed4ad51dddcc5f0dfda6a54fb45f78b1d86af Mon Sep 17 00:00:00 2001 From: Teddysun Date: Tue, 13 Jan 2015 17:02:06 +0800 Subject: [PATCH] Fix get IP address backup method --- shadowsocks-go.sh | 4 ++-- shadowsocks-libev-debian.sh | 4 ++-- shadowsocks-libev.sh | 4 ++-- shadowsocks.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/shadowsocks-go.sh b/shadowsocks-go.sh index e5fc920..41eb42c 100644 --- a/shadowsocks-go.sh +++ b/shadowsocks-go.sh @@ -91,8 +91,8 @@ function pre_install(){ # Get IP address echo "Getting Public IP address, Please wait a moment..." IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1` - if [ -z $IP ]; then - IP=`curl -s ifconfig.me/ip` + if [ $? -ne 0 -o -z $IP ]; then + IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'` fi echo -e "Your main public IP is\t\033[32m$IP\033[0m" echo "" diff --git a/shadowsocks-libev-debian.sh b/shadowsocks-libev-debian.sh index 7c40a40..fc0653a 100644 --- a/shadowsocks-libev-debian.sh +++ b/shadowsocks-libev-debian.sh @@ -73,8 +73,8 @@ function pre_install(){ # Get IP address echo "Getting Public IP address, Please wait a moment..." IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1` - if [ -z $IP ]; then - IP=`curl -s ifconfig.me/ip` + if [ $? -ne 0 -o -z $IP ]; then + IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'` fi #Current folder cur_dir=`pwd` diff --git a/shadowsocks-libev.sh b/shadowsocks-libev.sh index 07fc07e..b0fb718 100644 --- a/shadowsocks-libev.sh +++ b/shadowsocks-libev.sh @@ -88,8 +88,8 @@ function pre_install(){ # Get IP address echo "Getting Public IP address, Please wait a moment..." IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1` - if [ -z $IP ]; then - IP=`curl -s ifconfig.me/ip` + if [ $? -ne 0 -o -z $IP ]; then + IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'` fi echo -e "Your main public IP is\t\033[32m$IP\033[0m" echo "" diff --git a/shadowsocks.sh b/shadowsocks.sh index d38ca4e..06a4bb5 100644 --- a/shadowsocks.sh +++ b/shadowsocks.sh @@ -88,8 +88,8 @@ function pre_install(){ # Get IP address echo "Getting Public IP address, Please wait a moment..." IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1` - if [ -z $IP ]; then - IP=`curl -s ifconfig.me/ip` + if [ $? -ne 0 -o -z $IP ]; then + IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'` fi echo -e "Your main public IP is\t\033[32m$IP\033[0m" echo ""