check_download.sh 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. #!/bin/bash
  2. # Author: Alpha Eva <kaneawk AT gmail.com>
  3. #
  4. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  5. #
  6. # Project home page:
  7. # https://oneinstack.com
  8. # https://github.com/lj2007331/oneinstack
  9. checkDownload() {
  10. mirrorLink=http://mirrors.linuxeye.com/oneinstack/src
  11. pushd ${oneinstack_dir}/src
  12. # Web
  13. if [ "${Web_yn}" == 'y' ];then
  14. echo "Download openSSL..."
  15. src_url=https://www.openssl.org/source/openssl-${openssl_version}.tar.gz && Download_src
  16. if [ "${Nginx_version}" == "1" ];then
  17. echo "Download nginx..."
  18. src_url=http://nginx.org/download/nginx-${nginx_version}.tar.gz && Download_src
  19. fi
  20. if [ "${Nginx_version}" == "2" ];then
  21. echo "Download tengine..."
  22. src_url=http://tengine.taobao.org/download/tengine-${tengine_version}.tar.gz && Download_src
  23. fi
  24. if [ "${Nginx_version}" == "3" ];then
  25. echo "Download openresty..."
  26. src_url=https://openresty.org/download/openresty-${openresty_version}.tar.gz && Download_src
  27. fi
  28. if [[ "${Nginx_version}" =~ ^[1-3]$ || ${Apache_version} == "1" ]];then
  29. echo "Download pcre..."
  30. src_url=${mirrorLink}/pcre-${pcre_version}.tar.gz && Download_src
  31. fi
  32. # apache
  33. if [ "${Apache_version}" == "1" ];then
  34. echo "Download apache 2.4..."
  35. src_url=http://archive.apache.org/dist/apr/apr-${apr_version}.tar.gz && Download_src
  36. src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_version}.tar.gz && Download_src
  37. src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache_4_version}.tar.gz && Download_src
  38. fi
  39. if [ "${Apache_version}" == "2" ];then
  40. echo "Download apache 2.2..."
  41. src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache_2_version}.tar.gz && Download_src
  42. echo "Download mod_remoteip.c for apache 2.2..."
  43. src_url=${mirrorLink}/mod_remoteip.c && Download_src
  44. fi
  45. # tomcat
  46. if [ "${Tomcat_version}" == "1" ];then
  47. echo "Download tomcat 8..."
  48. src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_8_version}/apache-tomcat-${tomcat_8_version}.tar.gz && Download_src
  49. src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_8_version}/catalina-jmx-remote.jar && Download_src
  50. fi
  51. if [ "${Tomcat_version}" == "2" ];then
  52. echo "Download tomcat 7..."
  53. src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_7_version}/apache-tomcat-${tomcat_7_version}.tar.gz && Download_src
  54. src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_7_version}/catalina-jmx-remote.jar && Download_src
  55. fi
  56. if [ "${Tomcat_version}" == "3" ];then
  57. echo "Download tomcat 6..."
  58. src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_6_version}/apache-tomcat-${tomcat_6_version}.tar.gz && Download_src
  59. src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_6_version}/catalina-jmx-remote.jar && Download_src
  60. fi
  61. if [[ "${JDK_version}" =~ ^[1-3]$ ]];then
  62. if [ "${JDK_version}" == "1" ];then
  63. echo "Download jdk 1.8..."
  64. JDK_FILE="jdk-$(echo ${jdk_8_version} | awk -F. '{print $2}')u$(echo ${jdk_8_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz"
  65. fi
  66. if [ "${JDK_version}" == "2" ];then
  67. echo "Download jdk 1.7..."
  68. JDK_FILE="jdk-$(echo ${jdk_7_version} | awk -F. '{print $2}')u$(echo ${jdk_7_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz"
  69. fi
  70. if [ "${JDK_version}" == "3" ];then
  71. echo "Download jdk 1.6..."
  72. JDK_FILE="jdk-$(echo ${jdk_6_version} | awk -F. '{print $2}')u$(echo ${jdk_6_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.bin"
  73. fi
  74. src_url=http://mirrors.linuxeye.com/jdk/${JDK_FILE} && Download_src
  75. fi
  76. fi
  77. if [ "${DB_yn}" == "y" ];then
  78. if [[ "${DB_version}" =~ ^[1,4,7]$ ]] && [ "${dbInstallMethods}" == "2" ];then
  79. echo "Download boost..."
  80. [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_BOOST=${mirrorLink} || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/${boost_version}
  81. boostVersion2=$(echo ${boost_version} | awk -F. '{print $1}')_$(echo ${boost_version} | awk -F. '{print $2}')_$(echo ${boost_version} | awk -F. '{print $3}')
  82. src_url=${DOWN_ADDR_BOOST}/boost_${boostVersion2}.tar.gz && Download_src
  83. fi
  84. if [ "${DB_version}" == "1" ];then
  85. # mysql 5.7
  86. if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
  87. DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.7
  88. else
  89. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  90. if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ];then
  91. DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7
  92. else
  93. DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6
  94. DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
  95. fi
  96. else
  97. if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ];then
  98. DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7
  99. else
  100. DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.7
  101. DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
  102. fi
  103. fi
  104. fi
  105. if [ "${dbInstallMethods}" == "1" ];then
  106. echo "Download mysql 5.7 binary package..."
  107. FILE_NAME=mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
  108. elif [ "${dbInstallMethods}" == "2" ];then
  109. echo "Download mysql 5.7 source package..."
  110. FILE_NAME=mysql-${mysql_5_7_version}.tar.gz
  111. fi
  112. wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
  113. wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
  114. MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
  115. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
  116. wget -4c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
  117. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
  118. done
  119. fi
  120. if [ "${DB_version}" == "2" ];then
  121. # mysql 5.6
  122. if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == 'True' ];then
  123. DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.6
  124. else
  125. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  126. if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ];then
  127. DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6
  128. else
  129. DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6
  130. DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
  131. fi
  132. else
  133. if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ];then
  134. DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6
  135. else
  136. DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.6
  137. DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
  138. fi
  139. fi
  140. fi
  141. if [ "${dbInstallMethods}" == "1" ];then
  142. echo "Download mysql 5.6 binary package..."
  143. FILE_NAME=mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
  144. elif [ "${dbInstallMethods}" == "2" ];then
  145. echo "Download MySQL 5.5 source package..."
  146. FILE_NAME=mysql-${mysql_5_6_version}.tar.gz
  147. fi
  148. wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
  149. wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
  150. MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
  151. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
  152. wget -4c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
  153. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
  154. done
  155. fi
  156. if [ "${DB_version}" == "3" ];then
  157. # mysql 5.5
  158. if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == 'True' ];then
  159. DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.5
  160. else
  161. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  162. if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ];then
  163. DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.5
  164. else
  165. DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.5
  166. DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
  167. fi
  168. else
  169. if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ];then
  170. DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.5
  171. else
  172. DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.5
  173. DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
  174. fi
  175. fi
  176. fi
  177. if [ "${dbInstallMethods}" == "1" ];then
  178. echo "Download mysql 5.5 binary package..."
  179. FILE_NAME=mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}.tar.gz
  180. elif [ "${dbInstallMethods}" == "2" ];then
  181. echo "Download MySQL 5.5 source package..."
  182. FILE_NAME=mysql-${mysql_5_5_version}.tar.gz
  183. src_url=${mirrorLink}/mysql-5.5-fix-arm-client_plugin.patch && Download_src
  184. fi
  185. wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
  186. wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
  187. MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
  188. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
  189. wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
  190. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
  191. done
  192. fi
  193. if [ "${DB_version}" == "4" ];then
  194. # mariaDB 10.1
  195. if [ "${dbInstallMethods}" == "1" ];then
  196. echo "Download mariaDB 10.1 binary package..."
  197. FILE_NAME=mariadb-${mariadb_10_1_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
  198. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  199. DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
  200. MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  201. [ -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}'); }
  202. else
  203. DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
  204. MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  205. fi
  206. elif [ "${dbInstallMethods}" == "2" ];then
  207. echo "Download mariaDB 10.1 source package..."
  208. FILE_NAME=mariadb-${mariadb_10_1_version}.tar.gz
  209. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  210. DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/source
  211. MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  212. [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
  213. else
  214. DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_1_version}/source
  215. MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_1_version}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  216. fi
  217. fi
  218. tryDlCount=0
  219. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
  220. wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
  221. let "tryDlCount++"
  222. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
  223. done
  224. if [ "${tryDlCount}" == "6" -o "${tryDlCount}" == "6" ];then
  225. echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
  226. kill -9 $$
  227. else
  228. echo "[${CMSG}${FILE_NAME}${CEND}] found."
  229. fi
  230. fi
  231. if [ "${DB_version}" == "5" ];then
  232. # mariaDB 10.0
  233. if [ "${dbInstallMethods}" == "1" ];then
  234. echo "Download mariaDB 10.0 binary package..."
  235. FILE_NAME=mariadb-${mariadb_10_0_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
  236. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  237. DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
  238. MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  239. [ -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}'); }
  240. else
  241. DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
  242. MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  243. fi
  244. elif [ "${dbInstallMethods}" == "2" ];then
  245. echo "Download mariaDB 10.0 source package..."
  246. FILE_NAME=mariadb-${mariadb_10_0_version}.tar.gz
  247. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  248. DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/source
  249. MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  250. [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
  251. else
  252. DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_0_version}/source
  253. MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_0_version}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  254. fi
  255. fi
  256. tryDlCount=0
  257. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
  258. wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
  259. let "tryDlCount++"
  260. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
  261. done
  262. if [ "${tryDlCount}" == "6" -o "${tryDlCount}" == "6" ];then
  263. echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
  264. kill -9 $$
  265. else
  266. echo "[${CMSG}${FILE_NAME}${CEND}] found."
  267. fi
  268. fi
  269. if [ "${DB_version}" == "6" ];then
  270. # mariaDB 5.5
  271. if [ "${dbInstallMethods}" == "1" ];then
  272. echo "Download mariaDB 5.5 binary package..."
  273. FILE_NAME=mariadb-${mariadb_5_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
  274. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  275. DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
  276. MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  277. [ -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}'); }
  278. else
  279. DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
  280. MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  281. fi
  282. elif [ "${dbInstallMethods}" == "2" ];then
  283. echo "Download mariaDB 10.0 source package..."
  284. FILE_NAME=mariadb-${mariadb_5_5_version}.tar.gz
  285. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  286. DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/source
  287. MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  288. [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
  289. else
  290. DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_5_5_version}/source
  291. MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_5_5_version}/source/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
  292. fi
  293. fi
  294. tryDlCount=0
  295. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
  296. wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
  297. let "tryDlCount++"
  298. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
  299. done
  300. if [ "${tryDlCount}" == "6" -o "${tryDlCount}" == "6" ];then
  301. echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
  302. kill -9 $$
  303. else
  304. echo "[${CMSG}${FILE_NAME}${CEND}] found."
  305. fi
  306. fi
  307. if [ "${DB_version}" == "7" ];then
  308. # precona 5.7
  309. if [ "${dbInstallMethods}" == "1" ];then
  310. echo "Download percona 5.7 binary package..."
  311. FILE_NAME=Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
  312. DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/binary/tarball
  313. PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  314. elif [ "${dbInstallMethods}" == "2" ];then
  315. echo "Download percona 5.7 source package..."
  316. FILE_NAME=percona-server-${percona_5_7_version}.tar.gz
  317. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  318. DOWN_ADDR_PERCONA=${mirrorLink}
  319. DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.7/source/tarball
  320. PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  321. [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
  322. else
  323. DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/source/tarball
  324. PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  325. fi
  326. fi
  327. tryDlCount=0
  328. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
  329. wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
  330. let "tryDlCount++"
  331. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
  332. done
  333. if [ "${tryDlCount}" == "6" -o "${tryDlCount}" == "6" ];then
  334. echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
  335. kill -9 $$
  336. else
  337. echo "[${CMSG}${FILE_NAME}${CEND}] found."
  338. fi
  339. fi
  340. if [ "${DB_version}" == "8" ];then
  341. # precona 5.6
  342. if [ "${dbInstallMethods}" == "1" ];then
  343. echo "Download percona 5.6 binary package..."
  344. perconaVerStr1=$(echo ${percona_5_6_version} | sed "s@-@-rel@")
  345. FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
  346. DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/binary/tarball
  347. PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  348. elif [ "${dbInstallMethods}" == "2" ];then
  349. echo "Download percona 5.6 source package..."
  350. FILE_NAME=percona-server-${percona_5_6_version}.tar.gz
  351. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  352. DOWN_ADDR_PERCONA=${mirrorLink}
  353. DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/source/tarball
  354. PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  355. [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
  356. else
  357. DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/source/tarball
  358. PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  359. fi
  360. fi
  361. tryDlCount=0
  362. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
  363. wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
  364. let "tryDlCount++"
  365. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
  366. done
  367. if [ "${tryDlCount}" == "6" -o "${tryDlCount}" == "6" ];then
  368. echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
  369. kill -9 $$
  370. else
  371. echo "[${CMSG}${FILE_NAME}${CEND}] found."
  372. fi
  373. fi
  374. if [ "${DB_version}" == "9" ];then
  375. # precona 5.5
  376. if [ "${dbInstallMethods}" == "1" ];then
  377. echo "Download percona 5.5 binary package..."
  378. perconaVerStr1=$(echo ${percona_5_5_version} | sed "s@-@-rel@")
  379. FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
  380. DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/binary/tarball
  381. PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/binary/tarball/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  382. elif [ "${dbInstallMethods}" == "2" ];then
  383. echo "Download percona 5.5 source package..."
  384. FILE_NAME=percona-server-${percona_5_5_version}.tar.gz
  385. if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
  386. DOWN_ADDR_PERCONA=${mirrorLink}
  387. DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/source/tarball
  388. PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  389. [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
  390. else
  391. DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/source/tarball
  392. PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
  393. fi
  394. fi
  395. tryDlCount=0
  396. while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
  397. wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
  398. let "tryDlCount++"
  399. [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
  400. done
  401. if [ "${tryDlCount}" == "6" ];then
  402. echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
  403. kill -9 $$
  404. else
  405. echo "[${CMSG}${FILE_NAME}${CEND}] found."
  406. fi
  407. fi
  408. fi
  409. # PHP
  410. if [ "${PHP_yn}" == "y" ];then
  411. # php 5.3 5.4 5.5 5.6 5.7
  412. echo "PHP common..."
  413. src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${libiconv_version}.tar.gz && Download_src
  414. src_url=https://curl.haxx.se/download/curl-${curl_version}.tar.gz && Download_src
  415. src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/${libmcrypt_version}/libmcrypt-${libmcrypt_version}.tar.gz && Download_src
  416. src_url=http://downloads.sourceforge.net/project/mhash/mhash/${mhash_version}/mhash-${mhash_version}.tar.gz && Download_src
  417. src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/${mcrypt_version}/mcrypt-${mcrypt_version}.tar.gz && Download_src
  418. src_url=${mirrorLink}/libiconv-glibc-2.16.patch && Download_src
  419. if [[ "${PHP_version}" =~ ^[1-3]$ ]];then
  420. # php 5.3 5.4 5.5
  421. src_url=${mirrorLink}/fpm-race-condition.patch && Download_src
  422. fi
  423. if [ "${PHP_version}" == "1" ];then
  424. # php 5.3
  425. src_url=${mirrorLink}/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch && Download_src
  426. src_url=${mirrorLink}/php5.3patch && Download_src
  427. if [[ "${Debian_version}" == "8" || "${Ubuntu_version}" == "16" ]];then
  428. if [ ! -e "/usr/local/openssl/lib/libcrypto.a" ];then
  429. src_url=${mirrorLink}/openssl-1.0.0s.tar.gz && Download_src
  430. fi
  431. fi
  432. src_url=http://www.php.net/distributions/php-${php_3_version}.tar.gz && Download_src
  433. fi
  434. if [ "${PHP_version}" == "2" ];then
  435. src_url=http://www.php.net/distributions/php-${php_4_version}.tar.gz && Download_src
  436. fi
  437. if [ "${PHP_version}" == "3" ];then
  438. src_url=http://www.php.net/distributions/php-${php_5_version}.tar.gz && Download_src
  439. fi
  440. if [ "${PHP_version}" == "4" ];then
  441. src_url=http://www.php.net/distributions/php-${php_6_version}.tar.gz && Download_src
  442. fi
  443. if [ "${PHP_version}" == "5" ];then
  444. src_url=http://www.php.net/distributions/php-${php_7_version}.tar.gz && Download_src
  445. fi
  446. # PHP OPCache
  447. if [ "${PHP_cache}" == "1" ] && [[ "$PHP_version" =~ ^[1,2]$ ]];then
  448. # php 5.3 5.4
  449. echo "Download Zend OPCache..."
  450. src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src
  451. fi
  452. if [ "${PHP_cache}" == "2" ] && [[ "$PHP_version" =~ ^[1-4]$ ]];then
  453. # php 5.3 5.4 5.5 5.6
  454. echo "Download xcache..."
  455. src_url=http://xcache.lighttpd.net/pub/Releases/${xcache_version}/xcache-${xcache_version}.tar.gz && Download_src
  456. fi
  457. if [ "${PHP_cache}" == "3" ] && [[ "$PHP_version" =~ ^[1-3]$ ]];then
  458. # php 5.3 5.4 5.5
  459. echo "Download apcu..."
  460. src_url=http://pecl.php.net/get/apcu-${apcu_version}.tgz && Download_src
  461. fi
  462. if [ "${PHP_cache}" == "4" -a "${PHP_version}" == "2" ];then
  463. echo "Download eaccelerator 1.0 dev..."
  464. src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src
  465. elif [ "${PHP_cache}" == "4" -a "${PHP_version}" == "1" ];then
  466. echo "Download eaccelerator 0.9..."
  467. src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-${eaccelerator_version}.tar.bz2 && Download_src
  468. fi
  469. # Zend Guard Loader
  470. if [ "${ZendGuardLoader_yn}" == "y" ];then
  471. if [ "${PHP_version}" == "4" ];then
  472. if [ "${OS_BIT}" == "64" ];then
  473. # 64 bit
  474. echo "Download zend loader for php 5.6..."
  475. src_url=${mirrorLink}/zend-loader-php5.6-linux-x86_64.tar.gz && Download_src
  476. else
  477. # 32 bit
  478. echo "Download zend loader for php 5.6..."
  479. src_url=${mirrorLink}/zend-loader-php5.6-linux-i386.tar.gz && Download_src
  480. fi
  481. fi
  482. if [ "${PHP_version}" == "3" ];then
  483. if [ "${OS_BIT}" == "64" ];then
  484. # 64 bit
  485. echo "Download zend loader for php 5.5..."
  486. src_url=${mirrorLink}/zend-loader-php5.5-linux-x86_64.tar.gz && Download_src
  487. else
  488. # 32 bit
  489. echo "Download zend loader for php 5.5..."
  490. src_url=${mirrorLink}/zend-loader-php5.5-linux-i386.tar.gz && Download_src
  491. fi
  492. fi
  493. if [ "${PHP_version}" == "2" ];then
  494. if [ "${OS_BIT}" == "64" ];then
  495. # 64 bit
  496. echo "Download zend loader for php 5.4..."
  497. src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src
  498. else
  499. # 32 bit
  500. echo "Download zend loader for php 5.4..."
  501. src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz && Download_src
  502. fi
  503. fi
  504. if [ "${PHP_version}" == "1" ];then
  505. if [ "${OS_BIT}" == "64" ];then
  506. # 64 bit
  507. echo "Download zend loader for php 5.3..."
  508. src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src
  509. else
  510. # 32 bit
  511. echo "Download zend loader for php 5.3..."
  512. src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz && Download_src
  513. fi
  514. fi
  515. fi
  516. if [ "${ionCube_yn}" == "y" ];then
  517. echo "Download ioncube..."
  518. if [ "${OS_BIT}" == '64' ];then
  519. src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && Download_src
  520. else
  521. src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && Download_src
  522. fi
  523. fi
  524. if [ "${Magick_yn}" == "y" ];then
  525. if [ "${Magick}" == "1" ];then
  526. echo "Download ImageMagick..."
  527. src_url=${mirrorLink}/ImageMagick-${ImageMagick_version}.tar.gz && Download_src
  528. if [ "${PHP_version}" == "1" ];then
  529. echo "Download image for php 5.3..."
  530. src_url=https://pecl.php.net/get/imagick-${imagick_for_php53_version}.tgz && Download_src
  531. else
  532. echo "Download imagick..."
  533. src_url=http://pecl.php.net/get/imagick-${imagick_version}.tgz && Download_src
  534. fi
  535. else
  536. echo "Download graphicsmagick..."
  537. src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${GraphicsMagick_version}/GraphicsMagick-${GraphicsMagick_version}.tar.gz && Download_src
  538. if [ "${PHP_version}" == "5" ];then
  539. echo "Download gmagick for php7..."
  540. src_url=https://pecl.php.net/get/gmagick-${gmagick_for_php7_version}.tgz && Download_src
  541. else
  542. echo "Download gmagick for php..."
  543. src_url=http://pecl.php.net/get/gmagick-${gmagick_version}.tgz && Download_src
  544. fi
  545. fi
  546. fi
  547. fi
  548. if [ "${FTP_yn}" == "y" ];then
  549. echo "Download pureftpd..."
  550. src_url=http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${pureftpd_version}.tar.gz && Download_src
  551. fi
  552. if [ "${phpMyAdmin_yn}" == "y" ];then
  553. echo "Download phpMyAdmin..."
  554. src_url=https://files.phpmyadmin.net/phpMyAdmin/${phpMyAdmin_version}/phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz && Download_src
  555. fi
  556. if [ "${redis_yn}" == "y" ];then
  557. echo "Download redis..."
  558. src_url=http://download.redis.io/releases/redis-${redis_version}.tar.gz && Download_src
  559. if [ "${OS}" == "CentOS" ];then
  560. echo "Download start-stop-daemon.c for CentOS..."
  561. src_url=${mirrorLink}/start-stop-daemon.c && Download_src
  562. fi
  563. # redis addon
  564. if [ "${PHP_version}" == "5" ];then
  565. echo "Download redis pecl for php7..."
  566. src_url=http://pecl.php.net/get/redis-${redis_pecl_for_php7_version}.tgz && Download_src
  567. else
  568. echo "Download redis pecl..."
  569. src_url=http://pecl.php.net/get/redis-${redis_pecl_version}.tgz && Download_src
  570. fi
  571. fi
  572. if [ "${memcached_yn}" == "y" ];then
  573. echo "Download memcached..."
  574. src_url=http://www.memcached.org/files/memcached-${memcached_version}.tar.gz && Download_src
  575. if [ "${PHP_version}" == "5" ];then
  576. echo "Download pecl memcache for php7..."
  577. src_url=${mirrorLink}/pecl-memcache-php7.tgz && Download_src
  578. echo "Download php-memcached for php7..."
  579. src_url=${mirrorLink}/php-memcached-php7.tgz && Download_src
  580. else
  581. echo "Download pecl memcache for php7..."
  582. src_url=http://pecl.php.net/get/memcache-${memcache_pecl_version}.tgz && Download_src
  583. echo "Download php-memcached for php7..."
  584. src_url=http://pecl.php.net/get/memcached-${memcached_pecl_version}.tgz && Download_src
  585. fi
  586. echo "Download libmemcached..."
  587. src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_version}/+download/libmemcached-${libmemcached_version}.tar.gz && Download_src
  588. fi
  589. if [ "${je_tc_malloc_yn}" == "y" ];then
  590. if [ "${je_tc_malloc}" == "1" ];then
  591. echo "Download jemalloc..."
  592. src_url=${mirrorLink}/jemalloc-${jemalloc_version}.tar.bz2 && Download_src
  593. elif [ "${je_tc_malloc}" == "2" ];then
  594. echo "Download tcmalloc..."
  595. src_url=${mirrorLink}/gperftools-${tcmalloc_version}.tar.gz && Download_src
  596. fi
  597. fi
  598. # others
  599. if [ "${OS}" == "CentOS" ];then
  600. echo "Download tmux for CentOS..."
  601. src_url=${mirrorLink}/libevent-${libevent_version}.tar.gz && Download_src
  602. src_url=${mirrorLink}/tmux-${tmux_version}.tar.gz && Download_src
  603. echo "Download htop for CentOS..."
  604. src_url=http://hisham.hm/htop/releases/${htop_version}/htop-${htop_version}.tar.gz && Download_src
  605. fi
  606. if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]];then
  607. echo "Download bison for Ubuntu..."
  608. src_url=http://ftp.gnu.org/gnu/bison/bison-${bison_version}.tar.gz && Download_src
  609. fi
  610. popd
  611. }