From 6d214d588de26d06f9c11dd83d6d80ed8c997a7a Mon Sep 17 00:00:00 2001 From: Teddysun Date: Sat, 12 Jul 2014 11:42:01 +0900 Subject: [PATCH] Fix get public IP problem --- shadowsocks-libev-debian.sh | 11 +++++++---- shadowsocks-libev.sh | 9 ++++++--- shadowsocks-nodejs.sh | 8 ++++++-- shadowsocks.sh | 9 ++++++--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/shadowsocks-libev-debian.sh b/shadowsocks-libev-debian.sh index ea96892..c86870b 100644 --- a/shadowsocks-libev-debian.sh +++ b/shadowsocks-libev-debian.sh @@ -18,9 +18,6 @@ echo "#" echo "#############################################################" echo "" -# Get IP address(Default No.1) -IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.*' | cut -d: -f2 | awk '{ print $1}' | head -1`; - # Install Shadowsocks-libev function install_shadowsocks_libev(){ rootness @@ -70,7 +67,13 @@ function pre_install(){ echo "Press any key to start...or Press Ctrl+C to cancel" char=`get_char` #Install necessary dependencies - apt-get install -y wget unzip build-essential autoconf libtool libssl-dev + apt-get install -y wget unzip curl build-essential autoconf libtool libssl-dev + # 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` + fi #Current folder cur_dir=`pwd` cd $cur_dir diff --git a/shadowsocks-libev.sh b/shadowsocks-libev.sh index 5dc208a..602be13 100644 --- a/shadowsocks-libev.sh +++ b/shadowsocks-libev.sh @@ -18,9 +18,6 @@ echo "#" echo "#############################################################" echo "" -# Get IP address(Default No.1) -IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.*' | cut -d: -f2 | awk '{ print $1}' | head -1`; - # Install Shadowsocks-libev function install_shadowsocks_libev(){ rootness @@ -73,6 +70,12 @@ function pre_install(){ #Install necessary dependencies yum install -y wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent yum install -y automake make curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel + # 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` + fi #Current folder cur_dir=`pwd` cd $cur_dir diff --git a/shadowsocks-nodejs.sh b/shadowsocks-nodejs.sh index 9637964..6609849 100644 --- a/shadowsocks-nodejs.sh +++ b/shadowsocks-nodejs.sh @@ -18,8 +18,6 @@ echo "#" echo "#############################################################" echo "" -# Get IP address(Default No.1) -IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.*' | cut -d: -f2 | awk '{ print $1}' | head -1`; # Get Nodejs latest version NODEJS_VER=`curl -s http://nodejs.org/download/ | awk -F'' '/Current version/{print $2}' | cut -d '<' -f 1` @@ -75,6 +73,12 @@ function pre_install(){ #Install necessary dependencies yum install -y wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent yum install -y automake make curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel + # 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` + fi #Current folder cur_dir=`pwd` cd $cur_dir diff --git a/shadowsocks.sh b/shadowsocks.sh index 8b37e3a..61c261f 100644 --- a/shadowsocks.sh +++ b/shadowsocks.sh @@ -18,9 +18,6 @@ echo "#" echo "#############################################################" echo "" -# Get IP address -IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.*' | cut -d: -f2 | awk '{ print $1}' | head -1`; - # Install Shadowsocks function install_shadowsocks(){ rootness @@ -73,6 +70,12 @@ function pre_install(){ #Install necessary dependencies yum install -y wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent yum install -y automake make curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel + # 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` + fi #Current folder cur_dir=`pwd` cd $cur_dir