Update get public IP address method

This commit is contained in:
Teddysun 2015-03-24 17:04:12 +08:00
parent a0d8c5b9e7
commit 44d7df50e3
4 changed files with 8 additions and 8 deletions

View File

@ -110,8 +110,8 @@ function pre_install(){
fi fi
# Get IP address # Get IP address
echo "Getting Public IP address, Please wait a moment..." echo "Getting Public IP address, Please wait a moment..."
IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1) IP=$(wget -qO- ipv4.icanhazip.com)
if [ $? -ne 0 -o -z $IP ]; then if [[ "$IP" = "" ]]; then
IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}') IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}')
fi fi
echo -e "Your main public IP is\t\033[32m$IP\033[0m" echo -e "Your main public IP is\t\033[32m$IP\033[0m"

View File

@ -73,8 +73,8 @@ function pre_install(){
apt-get install -y wget unzip curl build-essential autoconf libtool libssl-dev apt-get install -y wget unzip curl build-essential autoconf libtool libssl-dev
# Get IP address # Get IP address
echo "Getting Public IP address, Please wait a moment..." echo "Getting Public IP address, Please wait a moment..."
IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1) IP=$(wget -qO- ipv4.icanhazip.com)
if [ $? -ne 0 -o -z $IP ]; then if [[ "$IP" = "" ]]; then
IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}') IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}')
fi fi
echo -e "Your main public IP is\t\033[32m$IP\033[0m" echo -e "Your main public IP is\t\033[32m$IP\033[0m"

View File

@ -87,8 +87,8 @@ function pre_install(){
yum install -y automake make curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel yum install -y automake make curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel
# Get IP address # Get IP address
echo "Getting Public IP address, Please wait a moment..." echo "Getting Public IP address, Please wait a moment..."
IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1` IP=$(wget -qO- ipv4.icanhazip.com)
if [ $? -ne 0 -o -z $IP ]; then if [[ "$IP" = "" ]]; then
IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'` IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'`
fi fi
echo -e "Your main public IP is\t\033[32m$IP\033[0m" echo -e "Your main public IP is\t\033[32m$IP\033[0m"

View File

@ -107,8 +107,8 @@ function pre_install(){
fi fi
# Get IP address # Get IP address
echo "Getting Public IP address, Please wait a moment..." echo "Getting Public IP address, Please wait a moment..."
IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1) IP=$(wget -qO- ipv4.icanhazip.com)
if [ $? -ne 0 -o -z $IP ]; then if [[ "$IP" = "" ]]; then
IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}') IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}')
fi fi
echo -e "Your main public IP is\t\033[32m$IP\033[0m" echo -e "Your main public IP is\t\033[32m$IP\033[0m"