Browse Source

Fixed bug

lj2007331 8 years ago
parent
commit
d5c178dcdb
4 changed files with 10 additions and 9 deletions
  1. 3 3
      include/get_ipaddr_state.py
  2. 2 2
      include/get_public_ipaddr.py
  3. 4 3
      install.sh
  4. 1 1
      upgrade.sh

+ 3 - 3
include/get_ipaddr_state.py

@@ -3,13 +3,13 @@
 try:
     import sys,urllib2,socket
     socket.setdefaulttimeout(10)
-    apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[2] 
+    apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[1]
     content = urllib2.urlopen(apiurl).read()
     data = eval(content)['data']
     code = eval(content)['code']
     if code == 0:
-        print data[sys.argv[1]]
+        print data['country_id'],data['isp_id']
     else:
         print data
 except:
-    print "Usage:%s {country_id|isp_id} IP" % sys.argv[0]
+    print "Usage:%s IP" % sys.argv[0]

+ 2 - 2
include/get_public_ipaddr.py

@@ -3,10 +3,10 @@ import re,urllib2
 class Get_public_ip:
     def getip(self):
         try:
-            myip = self.visit("http://ipv4.icanhazip.com/")
+            myip = self.visit("http://ip.chinaz.com/getip.aspx")
         except:
             try:
-                myip = self.visit("http://www.whereismyip.com/")
+                myip = self.visit("http://ipv4.icanhazip.com/")
             except:
                 myip = "So sorry!!!"
         return myip

+ 4 - 3
install.sh

@@ -449,10 +449,11 @@ while :; do echo
 done
 
 # get the IP information
-PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
-IPADDR_COUNTRY=`./include/get_ipaddr_state.py country_id $PUBLIC_IPADDR`
 IPADDR=`./include/get_ipaddr.py`
-[ "`./include/get_ipaddr_state.py isp_id $PUBLIC_IPADDR`"x == '1000323'x ] && IPADDR_ISP=aliyun
+PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
+IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
+IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
+[ "`echo $IPADDR_COUNTRY_ISP | awk '{print $2}'`"x == '1000323'x ] && IPADDR_ISP=aliyun
 
 # init
 . ./include/memory.sh

+ 1 - 1
upgrade.sh

@@ -38,7 +38,7 @@ sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
 
 # get the IP information
 PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
-IPADDR_COUNTRY=`./include/get_ipaddr_state.py country_id $PUBLIC_IPADDR`
+IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
 
 Usage(){
 printf "