Parcourir la source

Update get_ipaddr_state.py

lj2007331 il y a 8 ans
Parent
commit
573aed9eab

+ 2 - 2
include/demo.sh

@@ -11,10 +11,10 @@
 DEMO() {
 cd $oneinstack_dir/src
 
-[ "$IPADDR_STATE"x == "CN"x ] && /bin/cp ../config/index_cn.html $wwwroot_dir/default/index.html || /bin/cp ../config/index.html $wwwroot_dir/default
+[ "$IPADDR_COUNTRY"x == "CN"x ] && /bin/cp ../config/index_cn.html $wwwroot_dir/default/index.html || /bin/cp ../config/index.html $wwwroot_dir/default
 
 if [ -e "$php_install_dir/bin/php" ];then
-    if [ "$IPADDR_STATE"x == "CN"x ];then
+    if [ "$IPADDR_COUNTRY"x == "CN"x ];then
         src_url=http://mirrors.linuxeye.com/oneinstack/src/tz.zip && Download_src
         unzip -q tz.zip -d $wwwroot_dir/default
     else

+ 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[1]
+    apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[2] 
     content = urllib2.urlopen(apiurl).read()
     data = eval(content)['data']
     code = eval(content)['code']
     if code == 0:
-        print data['country']
+        print data[sys.argv[1]]
     else:
         print data
 except:
-    print "Usage:%s IP" % sys.argv[0]
+    print "Usage:%s {country_id|isp} IP" % sys.argv[0]

+ 1 - 1
include/mariadb-10.0.sh

@@ -13,7 +13,7 @@ cd $oneinstack_dir/src
 
 FILE_NAME=mariadb-${mariadb_10_0_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
 
-if [ "$IPADDR_STATE"x == "CN"x ];then
+if [ "$IPADDR_COUNTRY"x == "CN"x ];then
     DOWN_ADDR_MARIADB=http://mirrors.aliyun.com/mariadb/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a
     MARAIDB_TAR_MD5=`curl -Lk $DOWN_ADDR_MARIADB/md5sums.txt | grep $FILE_NAME | awk '{print $1}'`
     [ -z "$MARAIDB_TAR_MD5" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a; MARAIDB_TAR_MD5=`curl -Lk $DOWN_ADDR_MARIADB/md5sums.txt | grep $FILE_NAME | awk '{print $1}'`; }

+ 1 - 1
include/mariadb-10.1.sh

@@ -13,7 +13,7 @@ cd $oneinstack_dir/src
 
 FILE_NAME=mariadb-${mariadb_10_1_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
 
-if [ "$IPADDR_STATE"x == "CN"x ];then
+if [ "$IPADDR_COUNTRY"x == "CN"x ];then
     DOWN_ADDR_MARIADB=http://mirrors.aliyun.com/mariadb/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a
     MARAIDB_TAR_MD5=`curl -Lk $DOWN_ADDR_MARIADB/md5sums.txt | grep $FILE_NAME | awk '{print $1}'`
     [ -z "$MARAIDB_TAR_MD5" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a; MARAIDB_TAR_MD5=`curl -Lk $DOWN_ADDR_MARIADB/md5sums.txt | grep $FILE_NAME | awk '{print $1}'`; }

+ 1 - 1
include/mariadb-5.5.sh

@@ -13,7 +13,7 @@ cd $oneinstack_dir/src
 
 FILE_NAME=mariadb-${mariadb_5_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
 
-if [ "$IPADDR_STATE"x == "CN"x ];then
+if [ "$IPADDR_COUNTRY"x == "CN"x ];then
     DOWN_ADDR_MARIADB=http://mirrors.aliyun.com/mariadb/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a
     MARAIDB_TAR_MD5=`curl -Lk $DOWN_ADDR_MARIADB/md5sums.txt | grep $FILE_NAME | awk '{print $1}'`
     [ -z "$MARAIDB_TAR_MD5" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a; MARAIDB_TAR_MD5=`curl -Lk $DOWN_ADDR_MARIADB/md5sums.txt | grep $FILE_NAME | awk '{print $1}'`; }

+ 2 - 2
include/mysql-5.5.sh

@@ -11,10 +11,10 @@
 Install_MySQL-5-5() {
 cd $oneinstack_dir/src
 
-if [ "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
+if [ "$IPADDR_COUNTRY"x == "CN"x -a "$IPADDR_ISP" == 'aliyun' -a "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
     DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.5
 else
-    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.5 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.5
+    [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.5 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.5
 fi
 
 FILE_NAME=mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}.tar.gz

+ 2 - 2
include/mysql-5.6.sh

@@ -11,10 +11,10 @@
 Install_MySQL-5-6() {
 cd $oneinstack_dir/src
 
-if [ "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
+if [ "$IPADDR_COUNTRY"x == "CN"x -a "$IPADDR_ISP" == 'aliyun' -a "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
     DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.6
 else
-    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6
+    [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6
 fi
 
 FILE_NAME=mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz

+ 2 - 2
include/mysql-5.7.sh

@@ -11,10 +11,10 @@
 Install_MySQL-5-7() {
 cd $oneinstack_dir/src
 
-if [ "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
+if [ "$IPADDR_COUNTRY"x == "CN"x -a "$IPADDR_ISP" == 'aliyun' -a "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
     DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.7
 else
-    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.7 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7
+    [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.7 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7
 fi
 
 FILE_NAME=mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz

+ 1 - 1
include/percona-5.7.sh

@@ -10,7 +10,7 @@
 
 Install_Percona-5-7() {
 cd $oneinstack_dir/src
-[ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR_BOOST=http://mirrors.linuxeye.com/oneinstack/src || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/1.59.0
+[ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR_BOOST=http://mirrors.linuxeye.com/oneinstack/src || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/1.59.0
 
 if [ ! -e "/usr/local/lib/libboost_system.so" ];then
     src_url=$DOWN_ADDR_BOOST/boost_1_59_0.tar.gz && Download_src

+ 2 - 2
include/upgrade_db.sh

@@ -14,14 +14,14 @@ cd $oneinstack_dir/src
 OLD_DB_version_tmp=`$db_install_dir/bin/mysql -V | awk '{print $5}' | awk -F, '{print $1}'`
 DB_tmp=`echo $OLD_DB_version_tmp | awk -F'-' '{print $2}'`
 if [ "$DB_tmp" == 'MariaDB' ];then
-    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR=http://mirrors.aliyun.com/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f
+    [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=http://mirrors.aliyun.com/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f
     DB=MariaDB
     OLD_DB_version=`echo $OLD_DB_version_tmp | awk -F'-' '{print $1}'`
 elif [ -n "$DB_tmp" -a "$DB_tmp" != 'MariaDB' ];then
     DB=Percona
     OLD_DB_version=$OLD_DB_version_tmp
 else
-    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR=http://mirrors.sohu.com/mysql || DOWN_ADDR=http://cdn.mysql.com/Downloads
+    [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=http://mirrors.sohu.com/mysql || DOWN_ADDR=http://cdn.mysql.com/Downloads
     DB=MySQL
     OLD_DB_version=$OLD_DB_version_tmp
 fi

+ 2 - 1
install.sh

@@ -34,7 +34,8 @@ sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
 # get the IP information
 IPADDR=`./include/get_ipaddr.py`
 PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
-[ "`./include/get_ipaddr_state.py $PUBLIC_IPADDR`" == '\u4e2d\u56fd' ] && IPADDR_STATE=CN
+IPADDR_COUNTRY=`./include/get_ipaddr_state.py country_id $PUBLIC_IPADDR`
+[ "`./include/get_ipaddr_state.py isp $PUBLIC_IPADDR`" == '\u963f\u91cc\u4e91' ] && IPADDR_ISP=aliyun
 
 mkdir -p $wwwroot_dir/default $wwwlogs_dir
 [ -d /data ] && chmod 755 /data

+ 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`
-[ "`./include/get_ipaddr_state.py $PUBLIC_IPADDR`" == '\u4e2d\u56fd' ] && IPADDR_STATE=CN
+IPADDR_COUNTRY=`./include/get_ipaddr_state.py country_id $PUBLIC_IPADDR`
 
 Usage(){
 printf "

+ 3 - 3
versions.txt

@@ -34,9 +34,9 @@ jdk_7_version=1.7.0_80
 jdk_6_version=1.6.0_45
 
 # PHP
-php_7_version=7.0.8
-php_6_version=5.6.23
-php_5_version=5.5.37
+php_7_version=7.0.9
+php_6_version=5.6.24
+php_5_version=5.5.38
 php_4_version=5.4.45
 php_3_version=5.3.29