You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1433 lines
50 KiB

2 years ago
8 months ago
2 years ago
2 months ago
2 years ago
1 year ago
3 days ago
1 year ago
2 years ago
8 months ago
2 years ago
1 year ago
2 years ago
2 months ago
3 days ago
2 months ago
2 years ago
8 months ago
2 months ago
2 years ago
8 months ago
2 years ago
1 year ago
2 months ago
1 year ago
2 months ago
1 year ago
2 years ago
2 months ago
2 years ago
1 year ago
2 years ago
8 months ago
6 months ago
8 months ago
2 years ago
8 months ago
2 months ago
6 months ago
2 years ago
2 months ago
2 years ago
8 months ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
8 months ago
2 months ago
2 years ago
8 months ago
2 years ago
8 months ago
2 years ago
3 months ago
2 years ago
2 months ago
2 years ago
2 months ago
2 years ago
3 months ago
2 years ago
2 years ago
11 months ago
8 months ago
11 months ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 months ago
2 years ago
2 months ago
2 years ago
1 year ago
2 years ago
2 months ago
2 years ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
11 months ago
1 year ago
2 years ago
2 months ago
2 years ago
1 year ago
11 months ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
11 months ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
8 months ago
2 years ago
8 months ago
2 years ago
2 months ago
2 years ago
1 year ago
2 years ago
2 months ago
2 years ago
3 days ago
2 years ago
4 months ago
2 years ago
2 months ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 months ago
2 years ago
8 months ago
2 years ago
8 months ago
2 months ago
2 years ago
1 year ago
2 years ago
2 years ago
2 months ago
2 years ago
2 years ago
2 months ago
1 year ago
2 years ago
1 year ago
  1. #!/bin/bash
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  3. export PATH
  4. LANG=en_US.UTF-8
  5. Btapi_Url='http://www.example.com'
  6. Check_Api=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/SetupCount)
  7. if [ "$Check_Api" != 'ok' ];then
  8. Red_Error "此宝塔第三方云端无法连接,因此安装过程已中止!";
  9. fi
  10. if [ $(whoami) != "root" ];then
  11. echo "请使用root权限执行宝塔安装命令!"
  12. exit 1;
  13. fi
  14. is64bit=$(getconf LONG_BIT)
  15. if [ "${is64bit}" != '64' ];then
  16. echo "抱歉, 当前面板版本不支持32位系统, 请使用64位系统或安装宝塔5.9!";
  17. exit 1
  18. fi
  19. Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
  20. if [ "${Centos6Check}" ];then
  21. echo "Centos6不支持安装宝塔面板,请更换Centos7/8安装宝塔面板"
  22. exit 1
  23. fi
  24. UbuntuCheck=$(cat /etc/issue|grep Ubuntu|awk '{print $2}'|cut -f 1 -d '.')
  25. if [ "${UbuntuCheck}" ] && [ "${UbuntuCheck}" -lt "16" ];then
  26. echo "Ubuntu ${UbuntuCheck}不支持安装宝塔面板,建议更换Ubuntu18/20安装宝塔面板"
  27. exit 1
  28. fi
  29. HOSTNAME_CHECK=$(cat /etc/hostname)
  30. if [ -z "${HOSTNAME_CHECK}" ];then
  31. echo "localhost" > /etc/hostname
  32. # echo "当前主机名hostname为空无法安装宝塔面板,请咨询服务器运营商设置好hostname后再重新安装"
  33. # exit 1
  34. fi
  35. UBUNTU_NO_LTS=$(cat /etc/issue|grep Ubuntu|grep -E "19|21|23|25")
  36. if [ "${UBUNTU_NO_LTS}" ];then
  37. echo "当前您使用的非Ubuntu-lts版本,无法进行宝塔面板的安装"
  38. echo "请使用Ubuntu-20/20/22/24进行安装宝塔面板"
  39. exit 1
  40. fi
  41. DEBIAN_9_C=$(cat /etc/issue|grep Debian|grep -E "8 |9 ")
  42. if [ "${DEBIAN_9_C}" ];then
  43. echo "当前您使用的Debian-8/9,官方已经停止支持、无法进行宝塔面板的安装"
  44. echo "请使用Debian-11/12进行安装宝塔面板"
  45. exit 1
  46. fi
  47. cd ~
  48. setup_path="/www"
  49. python_bin=$setup_path/server/panel/pyenv/bin/python
  50. cpu_cpunt=$(cat /proc/cpuinfo|grep processor|wc -l)
  51. panelPort=$(expr $RANDOM % 55535 + 10000)
  52. # if [ "$1" ];then
  53. # IDC_CODE=$1
  54. # fi
  55. Ready_Check(){
  56. WWW_DISK_SPACE=$(df |grep /www|awk '{print $4}')
  57. ROOT_DISK_SPACE=$(df |grep /$|awk '{print $4}')
  58. if [ "${ROOT_DISK_SPACE}" -le 412000 ];then
  59. df -h
  60. echo -e "系统盘剩余空间不足400M 无法继续安装宝塔面板!"
  61. echo -e "请尝试清理磁盘空间后再重新进行安装"
  62. exit 1
  63. fi
  64. if [ "${WWW_DISK_SPACE}" ] && [ "${WWW_DISK_SPACE}" -le 412000 ] ;then
  65. echo -e "/www盘剩余空间不足400M 无法继续安装宝塔面板!"
  66. echo -e "请尝试清理磁盘空间后再重新进行安装"
  67. exit 1
  68. fi
  69. # ROOT_DISK_INODE=$(df -i|grep /$|awk '{print $2}')
  70. # if [ "${ROOT_DISK_INODE}" != "0" ];then
  71. # ROOT_DISK_INODE_FREE=$(df -i|grep /$|awk '{print $4}')
  72. # if [ "${ROOT_DISK_INODE_FREE}" -le 1000 ];then
  73. # echo -e "系统盘剩余inodes空间不足1000,无法继续安装!"
  74. # echo -e "请尝试清理磁盘空间后再重新进行安装"
  75. # exit 1
  76. # fi
  77. # fi
  78. # WWW_DISK_INODE==$(df -i|grep /www|awk '{print $2}')
  79. # if [ "${WWW_DISK_INODE}" ] && [ "${WWW_DISK_INODE}" != "0" ] ;then
  80. # WWW_DISK_INODE_FREE=$(df -i|grep /www|awk '{print $4}')
  81. # if [ "${WWW_DISK_INODE_FREE}" ] && [ "${WWW_DISK_INODE_FREE}" -le 1000 ] ;then
  82. # echo -e "/www盘剩余inodes空间不足1000, 无法继续安装!"
  83. # echo -e "请尝试清理磁盘空间后再重新进行安装"
  84. # exit 1
  85. # fi
  86. # fi
  87. }
  88. GetSysInfo(){
  89. if [ -s "/etc/redhat-release" ];then
  90. SYS_VERSION=$(cat /etc/redhat-release)
  91. elif [ -s "/etc/issue" ]; then
  92. SYS_VERSION=$(cat /etc/issue)
  93. fi
  94. SYS_INFO=$(uname -a)
  95. SYS_BIT=$(getconf LONG_BIT)
  96. MEM_TOTAL=$(free -m|grep Mem|awk '{print $2}')
  97. CPU_INFO=$(getconf _NPROCESSORS_ONLN)
  98. echo -e ${SYS_VERSION}
  99. echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO}
  100. echo -e ${SYS_INFO}
  101. echo -e "============================================"
  102. echo -e "请截图以上报错信息发帖至论坛www.bt.cn/bbs求助"
  103. echo -e "============================================"
  104. if [ -f "/etc/redhat-release" ];then
  105. Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos')
  106. echo -e "============================================"
  107. echo -e "Centos7/8官方已经停止支持"
  108. echo -e "如是新安装系统服务器建议更换至Debian-12/Ubuntu-22/Centos-9系统安装宝塔面板"
  109. echo -e "============================================"
  110. fi
  111. if [ -f "/usr/sbin/setstatus" ] || [ -f "/usr/sbin/setstatus" ];then
  112. echo -e "=================================================="
  113. echo -e " 检测到为麒麟系统,可能默认开启安全功能导致安装失败"
  114. echo -e " 请执行以下命令关闭安全加固后,再重新安装宝塔面板看是否正常"
  115. echo -e " 命令:sudo setstatus softmode -p"
  116. echo -e "=================================================="
  117. fi
  118. SYS_SSL_LIBS=$(pkg-config --list-all | grep -q libssl)
  119. if [ -z "$SYS_SSL_LIBS" ];then
  120. echo "检测到缺少系统ssl相关依赖,可执行下面命令安装依赖后再重新安装宝塔看是否正常"
  121. echo "执行前请确保系统源正常"
  122. if [ -f "/usr/bin/yum" ];then
  123. echo "安装依赖命令: yum install openssl-devel -y"
  124. elif [ -f "/usr/bin/apt-get" ];then
  125. echo "安装依赖命令: apt-get install libssl-dev -y"
  126. fi
  127. rm -rf /www/server/panel/pyenv
  128. echo -e "=================================================="
  129. fi
  130. }
  131. Red_Error(){
  132. echo '=================================================';
  133. printf '\033[1;31;40m%b\033[0m\n' "$@";
  134. GetSysInfo
  135. exit 1;
  136. }
  137. Lock_Clear(){
  138. if [ -f "/etc/bt_crack.pl" ];then
  139. chattr -R -ia /www
  140. chattr -ia /etc/init.d/bt
  141. \cp -rpa /www/backup/panel/vhost/* /www/server/panel/vhost/
  142. mv /www/server/panel/BTPanel/__init__.bak /www/server/panel/BTPanel/__init__.py
  143. rm -f /etc/bt_crack.pl
  144. fi
  145. }
  146. Install_Check(){
  147. if [ "${INSTALL_FORCE}" ];then
  148. return
  149. fi
  150. echo -e "----------------------------------------------------"
  151. echo -e "检查已有其他Web/mysql环境,安装宝塔可能影响现有站点及数据"
  152. echo -e "Web/mysql service is alreday installed,Can't install panel"
  153. echo -e "----------------------------------------------------"
  154. echo -e "已知风险/Enter yes to force installation"
  155. read -p "输入yes强制安装: " yes;
  156. if [ "$yes" != "yes" ];then
  157. echo -e "------------"
  158. echo "取消安装"
  159. exit;
  160. fi
  161. INSTALL_FORCE="true"
  162. }
  163. System_Check(){
  164. MYSQLD_CHECK=$(ps -ef |grep mysqld|grep -v grep|grep -v /www/server/mysql)
  165. PHP_CHECK=$(ps -ef|grep php-fpm|grep master|grep -v /www/server/php)
  166. NGINX_CHECK=$(ps -ef|grep nginx|grep master|grep -v /www/server/nginx)
  167. HTTPD_CHECK=$(ps -ef |grep -E 'httpd|apache'|grep -v /www/server/apache|grep -v grep)
  168. if [ "${PHP_CHECK}" ] || [ "${MYSQLD_CHECK}" ] || [ "${NGINX_CHECK}" ] || [ "${HTTPD_CHECK}" ];then
  169. Install_Check
  170. fi
  171. }
  172. Set_Ssl(){
  173. SET_SSL=true
  174. if [ "${SSL_PL}" ];then
  175. SET_SSL=""
  176. fi
  177. }
  178. Add_lib_Install(){
  179. if [ -f "/etc/os-release" ];then
  180. . /etc/os-release
  181. OS_V=${VERSION_ID%%.*}
  182. if [ "${ID}" == "debian" ] && [[ "${OS_V}" =~ ^(11|12)$ ]];then
  183. OS_NAME=${ID}
  184. elif [ "${ID}" == "ubuntu" ] && [[ "${OS_V}" =~ ^(22|24)$ ]];then
  185. OS_NAME=${ID}
  186. elif [ "${ID}" == "centos" ] && [[ "${OS_V}" =~ ^(7)$ ]];then
  187. OS_NAME="el"
  188. elif [ "${ID}" == "opencloudos" ] && [[ "${OS_V}" =~ ^(9)$ ]];then
  189. OS_NAME=${ID}
  190. elif [ "${ID}" == "tencentos" ] && [[ "${OS_V}" =~ ^(4)$ ]];then
  191. OS_NAME=${ID}
  192. elif [ "${ID}" == "hce" ] && [[ "${OS_V}" =~ ^(2)$ ]];then
  193. OS_NAME=${ID}
  194. elif { [ "${ID}" == "almalinux" ] || [ "${ID}" == "centos" ] || [ "${ID}" == "rocky" ]; } && [[ "${OS_V}" =~ ^(9)$ ]]; then
  195. OS_NAME="el"
  196. fi
  197. fi
  198. X86_CHECK=$(uname -m|grep x86_64)
  199. if [ "${OS_NAME}" ] && [ "${X86_CHECK}" ];then
  200. if [ "${PM}" = "yum" ]; then
  201. mtype="1"
  202. elif [ "${PM}" = "apt-get" ]; then
  203. mtype="4"
  204. fi
  205. cd /www/server/panel/class
  206. btpython -c "import panelPlugin; plugin = panelPlugin.panelPlugin(); plugin.check_install_lib('${mtype}')"
  207. echo "True" > /tmp/panelTask.pl
  208. echo "True" > /www/server/panel/install/ins_lib.pl
  209. fi
  210. }
  211. Get_Pack_Manager(){
  212. if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
  213. PM="yum"
  214. elif [ -f "/usr/bin/apt-get" ] && [ -f "/usr/bin/dpkg" ]; then
  215. PM="apt-get"
  216. fi
  217. }
  218. Set_Repo_Url(){
  219. if [ "${PM}"="apt-get" ];then
  220. ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
  221. Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
  222. if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
  223. return
  224. fi
  225. CN_CHECK=$(curl -sS --connect-timeout 10 -m 10 https://api.bt.cn/api/isCN)
  226. if [ "${CN_CHECK}" == "True" ];then
  227. SOURCE_URL_CHECK=$(grep -E 'security.ubuntu.com|archive.ubuntu.com|security.debian.org|deb.debian.org' /etc/apt/sources.list)
  228. # if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ];then
  229. # SOURCE_URL_CHECK=$(grep -E 'security.ubuntu.com|archive.ubuntu.com|security.debian.org|deb.debian.org' /etc/apt/sources.list.d/ubuntu.sources)
  230. # fi
  231. fi
  232. #GET_SOURCES_URL=$(cat /etc/apt/sources.list|grep ^deb|head -n 1|awk -F[/:] '{print $4}')
  233. GET_SOURCES_URL=$(cat /etc/apt/sources.list|grep ^deb|head -n 1|sed -E 's|^[^ ]+ https?://([^/]+).*|\1|')
  234. # if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ];then
  235. # GET_SOURCES_URL=$(cat /etc/apt/sources.list.d/ubuntu.sources|grep URIs:|head -n 1|sed -E 's|^[^ ]+ https?://([^/]+).*|\1|')
  236. # fi
  237. NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${GET_SOURCES_URL} -o /dev/null)
  238. NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $1}')
  239. TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $2 * 1000}'|cut -d '.' -f 1)
  240. if { [ "${NODE_STATUS}" != "200" ] && [ "${NODE_STATUS}" != "301" ]; } || [ "${TIME_TOTAL}" -ge "150" ] || [ "${SOURCE_URL_CHECK}" ]; then
  241. \cp -rpa /etc/apt/sources.list /etc/apt/sources.list.btbackup
  242. apt_lists=(mirrors.cloud.tencent.com mirrors.163.com repo.huaweicloud.com mirrors.tuna.tsinghua.edu.cn mirrors.aliyun.com mirrors.ustc.edu.cn )
  243. for list in ${apt_lists[@]};
  244. do
  245. NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${list} -o /dev/null)
  246. NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $1}')
  247. TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $2 * 1000}'|cut -d '.' -f 1)
  248. if [ "${NODE_STATUS}" == "200" ] || [ "${NODE_STATUS}" == "301" ];then
  249. if [ "${TIME_TOTAL}" -le "150" ];then
  250. if [ -f "/etc/apt/sources.list" ];then
  251. sed -i "s/${GET_SOURCES_URL}/${list}/g" /etc/apt/sources.list
  252. sed -i "s/cn.security.ubuntu.com/${list}/g" /etc/apt/sources.list
  253. sed -i "s/cn.archive.ubuntu.com/${list}/g" /etc/apt/sources.list
  254. sed -i "s/security.ubuntu.com/${list}/g" /etc/apt/sources.list
  255. sed -i "s/archive.ubuntu.com/${list}/g" /etc/apt/sources.list
  256. sed -i "s/security.debian.org/${list}/g" /etc/apt/sources.list
  257. sed -i "s/deb.debian.org/${list}/g" /etc/apt/sources.list
  258. fi
  259. # if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ];then
  260. # \cp -rpa /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
  261. # sed -i "s/${GET_SOURCES_URL}/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
  262. # sed -i "s/cn.security.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
  263. # sed -i "s/cn.archive.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
  264. # sed -i "s/security.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
  265. # sed -i "s/archive.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
  266. # sed -i "s/security.debian.org/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
  267. # sed -i "s/deb.debian.org/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
  268. # fi
  269. break;
  270. fi
  271. fi
  272. done
  273. fi
  274. fi
  275. }
  276. Auto_Swap()
  277. {
  278. swap=$(free |grep Swap|awk '{print $2}')
  279. if [ "${swap}" -gt 1 ];then
  280. echo "Swap total sizse: $swap";
  281. return;
  282. fi
  283. if [ ! -d /www ];then
  284. mkdir /www
  285. fi
  286. echo "正在设置虚拟内存,请稍等..........";
  287. echo '---------------------------------------------';
  288. swapFile="/www/swap"
  289. dd if=/dev/zero of=$swapFile bs=1M count=1025
  290. mkswap -f $swapFile
  291. swapon $swapFile
  292. echo "$swapFile swap swap defaults 0 0" >> /etc/fstab
  293. swap=`free |grep Swap|awk '{print $2}'`
  294. if [ $swap -gt 1 ];then
  295. echo "Swap total sizse: $swap";
  296. return;
  297. fi
  298. sed -i "/\/www\/swap/d" /etc/fstab
  299. rm -f $swapFile
  300. }
  301. Service_Add(){
  302. if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ]; then
  303. chkconfig --add bt
  304. chkconfig --level 2345 bt on
  305. Centos9Check=$(cat /etc/redhat-release |grep ' 9')
  306. if [ "${Centos9Check}" ];then
  307. wget -O /usr/lib/systemd/system/btpanel.service ${download_Url}/init/systemd/btpanel.service
  308. systemctl enable btpanel
  309. fi
  310. elif [ "${PM}" == "apt-get" ]; then
  311. update-rc.d bt defaults
  312. fi
  313. }
  314. Set_Centos7_Repo(){
  315. # CN_YUM_URL=$(grep -E "aliyun|163|tencent|tsinghua" /etc/yum.repos.d/CentOS-Base.repo)
  316. # if [ -z "${CN_YUM_URL}" ];then
  317. # if [ -z "${download_Url}" ];then
  318. # download_Url="http://download.bt.cn"
  319. # fi
  320. # curl -Ss --connect-timeout 3 -m 60 ${download_Url}/install/vault-repo.sh|bash
  321. # return
  322. # fi
  323. MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "[^#]mirror.centos.org")
  324. if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
  325. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  326. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
  327. sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  328. fi
  329. TSU_MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "tuna.tsinghua.edu.cn")
  330. if [ "${TSU_MIRROR_CHECK}" ];then
  331. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  332. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
  333. sed -i 's|#baseurl=https://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  334. sed -i 's|#baseurl=http://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  335. sed -i 's|baseurl=https://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  336. sed -i 's|baseurl=http://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  337. fi
  338. ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
  339. Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
  340. if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
  341. return
  342. fi
  343. yum install unzip -y
  344. if [ "$?" != "0" ] ;then
  345. TAR_CHECK=$(which tar)
  346. if [ "$?" == "0" ] ;then
  347. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  348. if [ -z "${download_Url}" ];then
  349. download_Url="http://download.bt.cn"
  350. fi
  351. curl -Ss --connect-timeout 5 -m 60 -O ${download_Url}/src/el7repo.tar.gz
  352. rm -f /etc/yum.repos.d/*.repo
  353. tar -xvzf el7repo.tar.gz -C /etc/yum.repos.d/
  354. fi
  355. fi
  356. yum install unzip -y
  357. if [ "$?" != "0" ] ;then
  358. sed -i "s/vault.epel.cloud/mirrors.cloud.tencent.com/g" /etc/yum.repos.d/*.repo
  359. fi
  360. }
  361. Set_Centos8_Repo(){
  362. HUAWEI_CHECK=$(cat /etc/motd |grep "Huawei Cloud")
  363. if [ "${HUAWEI_CHECK}" ] && [ "${is64bit}" == "64" ];then
  364. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  365. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
  366. sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  367. rm -f /etc/yum.repos.d/epel.repo
  368. rm -f /etc/yum.repos.d/epel-*
  369. fi
  370. ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
  371. if [ "${ALIYUN_CHECK}" ] && [ "${is64bit}" == "64" ] && [ ! -f "/etc/yum.repos.d/Centos-vault-8.5.2111.repo" ];then
  372. rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
  373. wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
  374. wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
  375. sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
  376. sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
  377. fi
  378. MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo |grep "[^#]mirror.centos.org")
  379. if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
  380. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  381. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
  382. sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  383. fi
  384. yum install unzip tar -y
  385. if [ "$?" != "0" ] ;then
  386. if [ -z "${download_Url}" ];then
  387. download_Url="http://download.bt.cn"
  388. fi
  389. if [ ! -f "/usr/bin/tar" ] ;then
  390. curl -Ss --connect-timeout 5 -m 60 -O ${download_Url}/src/tar-1.30-5.el8.x86_64.rpm
  391. yum install tar-1.30-5.el8.x86_64.rpm -y
  392. fi
  393. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  394. curl -Ss --connect-timeout 5 -m 60 -O ${download_Url}/src/el8repo.tar.gz
  395. rm -f /etc/yum.repos.d/*.repo
  396. tar -xvzf el8repo.tar.gz -C /etc/yum.repos.d/
  397. fi
  398. yum install unzip tar -y
  399. if [ "$?" != "0" ] ;then
  400. sed -i "s/vault.epel.cloud/mirrors.cloud.tencent.com/g" /etc/yum.repos.d/*.repo
  401. fi
  402. }
  403. get_node_url(){
  404. if [ "${PM}" = "yum" ]; then
  405. yum install wget -y
  406. fi
  407. if [ ! -f /bin/curl ];then
  408. if [ "${PM}" = "yum" ]; then
  409. yum install curl -y
  410. elif [ "${PM}" = "apt-get" ]; then
  411. apt-get install curl -y
  412. fi
  413. fi
  414. if [ -f "/www/node.pl" ];then
  415. download_Url=$(cat /www/node.pl)
  416. echo "Download node: $download_Url";
  417. echo '---------------------------------------------';
  418. return
  419. fi
  420. echo '---------------------------------------------';
  421. echo "Selected download node...";
  422. nodes=(https://dg2.bt.cn https://download.bt.cn https://ctcc1-node.bt.cn https://cmcc1-node.bt.cn https://ctcc2-node.bt.cn https://hk1-node.bt.cn https://na1-node.bt.cn https://jp1-node.bt.cn https://cf1-node.aapanel.com https://download.bt.cn);
  423. CURL_CHECK=$(which curl)
  424. if [ "$?" == "0" ];then
  425. CN_CHECK=$(curl -sS --connect-timeout 10 -m 10 https://api.bt.cn/api/isCN)
  426. if [ "${CN_CHECK}" == "True" ];then
  427. nodes=(https://dg2.bt.cn https://download.bt.cn https://ctcc1-node.bt.cn https://cmcc1-node.bt.cn https://ctcc2-node.bt.cn https://hk1-node.bt.cn);
  428. fi
  429. fi
  430. if [ "$1" ];then
  431. nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
  432. fi
  433. tmp_file1=/dev/shm/net_test1.pl
  434. tmp_file2=/dev/shm/net_test2.pl
  435. [ -f "${tmp_file1}" ] && rm -f ${tmp_file1}
  436. [ -f "${tmp_file2}" ] && rm -f ${tmp_file2}
  437. touch $tmp_file1
  438. touch $tmp_file2
  439. for node in ${nodes[@]};
  440. do
  441. NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/net_test|xargs)
  442. RES=$(echo ${NODE_CHECK}|awk '{print $1}')
  443. NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $2}')
  444. TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $3 * 1000 - 500 }'|cut -d '.' -f 1)
  445. if [ "${NODE_STATUS}" == "200" ];then
  446. if [ $TIME_TOTAL -lt 300 ];then
  447. if [ $RES -ge 1500 ];then
  448. echo "$RES $node" >> $tmp_file1
  449. fi
  450. else
  451. if [ $RES -ge 1500 ];then
  452. echo "$TIME_TOTAL $node" >> $tmp_file2
  453. fi
  454. fi
  455. i=$(($i+1))
  456. if [ $TIME_TOTAL -lt 300 ];then
  457. if [ $RES -ge 2390 ];then
  458. break;
  459. fi
  460. fi
  461. fi
  462. done
  463. NODE_URL=$(cat $tmp_file1|sort -r -g -t " " -k 1|head -n 1|awk '{print $2}')
  464. if [ -z "$NODE_URL" ];then
  465. NODE_URL=$(cat $tmp_file2|sort -g -t " " -k 1|head -n 1|awk '{print $2}')
  466. if [ -z "$NODE_URL" ];then
  467. NODE_URL='https://download.bt.cn';
  468. fi
  469. fi
  470. rm -f $tmp_file1
  471. rm -f $tmp_file2
  472. download_Url=$NODE_URL
  473. echo "Download node: $download_Url";
  474. echo '---------------------------------------------';
  475. }
  476. Remove_Package(){
  477. local PackageNmae=$1
  478. if [ "${PM}" == "yum" ];then
  479. isPackage=$(rpm -q ${PackageNmae}|grep "not installed")
  480. if [ -z "${isPackage}" ];then
  481. yum remove ${PackageNmae} -y
  482. fi
  483. elif [ "${PM}" == "apt-get" ];then
  484. isPackage=$(dpkg -l|grep ${PackageNmae})
  485. if [ "${PackageNmae}" ];then
  486. apt-get remove ${PackageNmae} -y
  487. fi
  488. fi
  489. }
  490. Install_RPM_Pack(){
  491. yumPath=/etc/yum.conf
  492. CentosStream8Check=$(cat /etc/redhat-release |grep Stream|grep 8)
  493. if [ "${CentosStream8Check}" ];then
  494. MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Stream-AppStream.repo|grep "[^#]mirror.centos.org")
  495. if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
  496. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  497. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
  498. sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  499. fi
  500. fi
  501. Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
  502. if [ "${Centos8Check}" ];then
  503. Set_Centos8_Repo
  504. fi
  505. Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
  506. if [ "${Centos7Check}" ];then
  507. Set_Centos7_Repo
  508. fi
  509. isExc=$(cat $yumPath|grep httpd)
  510. if [ "$isExc" = "" ];then
  511. echo "exclude=httpd nginx php mysql mairadb python-psutil python2-psutil" >> $yumPath
  512. fi
  513. if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el8") ];then
  514. yum config-manager --set-enabled powertools
  515. yum config-manager --set-enabled PowerTools
  516. fi
  517. if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el9") ];then
  518. dnf config-manager --set-enabled crb -y
  519. fi
  520. #SYS_TYPE=$(uname -a|grep x86_64)
  521. #yumBaseUrl=$(cat /etc/yum.repos.d/CentOS-Base.repo|grep baseurl=http|cut -d '=' -f 2|cut -d '$' -f 1|head -n 1)
  522. #[ "${yumBaseUrl}" ] && checkYumRepo=$(curl --connect-timeout 5 --head -s -o /dev/null -w %{http_code} ${yumBaseUrl})
  523. #if [ "${checkYumRepo}" != "200" ] && [ "${SYS_TYPE}" ];then
  524. # curl -Ss --connect-timeout 3 -m 60 http://download.bt.cn/install/yumRepo_select.sh|bash
  525. #fi
  526. #尝试同步时间(从bt.cn)
  527. echo 'Synchronizing system time...'
  528. getBtTime=$(curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/index/get_time)
  529. if [ "${getBtTime}" ];then
  530. date -s "$(date -d @$getBtTime +"%Y-%m-%d %H:%M:%S")"
  531. fi
  532. if [ -z "${Centos8Check}" ]; then
  533. yum install ntp -y
  534. rm -rf /etc/localtime
  535. ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  536. #尝试同步国际时间(从ntp服务器)
  537. ntpdate 0.asia.pool.ntp.org
  538. setenforce 0
  539. fi
  540. startTime=`date +%s`
  541. sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
  542. #yum remove -y python-requests python3-requests python-greenlet python3-greenlet
  543. yumPacks="libcurl-devel wget tar gcc make zip unzip openssl openssl-devel gcc libxml2 libxml2-devel libxslt* zlib zlib-devel libjpeg-devel libpng-devel libwebp libwebp-devel freetype freetype-devel lsof pcre pcre-devel vixie-cron crontabs icu libicu-devel c-ares libffi-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel qrencode at mariadb rsyslog net-tools"
  544. yum install -y ${yumPacks}
  545. for yumPack in ${yumPacks}
  546. do
  547. rpmPack=$(rpm -q ${yumPack})
  548. packCheck=$(echo ${rpmPack}|grep not)
  549. if [ "${packCheck}" ]; then
  550. yum install ${yumPack} -y
  551. fi
  552. done
  553. if [ -f "/usr/bin/dnf" ]; then
  554. dnf install -y redhat-rpm-config
  555. fi
  556. ALI_OS=$(cat /etc/redhat-release |grep "Alibaba Cloud Linux release 3")
  557. if [ -z "${ALI_OS}" ];then
  558. yum install epel-release -y
  559. fi
  560. }
  561. Install_Deb_Pack(){
  562. ln -sf bash /bin/sh
  563. UBUNTU_22=$(cat /etc/issue|grep "Ubuntu 22")
  564. UBUNTU_24=$(cat /etc/issue|grep "Ubuntu 24")
  565. if [ "${UBUNTU_22}" ] || [ "${UBUNTU_24}" ];then
  566. apt-get remove needrestart -y
  567. fi
  568. ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
  569. if [ "${ALIYUN_CHECK}" ] && [ "${UBUNTU_22}" ];then
  570. apt-get remove libicu70 -y
  571. fi
  572. apt-get update -y
  573. FNOS_CHECK=$(cat /etc/issue|grep fnOS)
  574. if [ "${FNOS_CHECK}" ];then
  575. apt-get install libc6 --allow-change-held-packages -y
  576. apt-get install libc6-dev --allow-change-held-packages -y
  577. fi
  578. apt-get install bash -y
  579. if [ -f "/usr/bin/bash" ];then
  580. ln -sf /usr/bin/bash /bin/sh
  581. fi
  582. apt-get install ruby -y
  583. apt-get install lsb-release -y
  584. #apt-get install ntp ntpdate -y
  585. #/etc/init.d/ntp stop
  586. #update-rc.d ntp remove
  587. #cat >>~/.profile<<EOF
  588. #TZ='Asia/Shanghai'; export TZ
  589. #EOF
  590. #rm -rf /etc/localtime
  591. #cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  592. #echo 'Synchronizing system time...'
  593. #ntpdate 0.asia.pool.ntp.org
  594. #apt-get upgrade -y
  595. LIBCURL_VER=$(dpkg -l|grep libcurl4|awk '{print $3}')
  596. if [ "${LIBCURL_VER}" == "7.68.0-1ubuntu2.8" ];then
  597. apt-get remove libcurl4 -y
  598. apt-get install curl -y
  599. fi
  600. debPacks="wget curl libcurl4-openssl-dev gcc make zip unzip tar openssl libssl-dev gcc libxml2 libxml2-dev zlib1g zlib1g-dev libjpeg-dev libpng-dev lsof libpcre3 libpcre3-dev cron net-tools swig build-essential libffi-dev libbz2-dev libncurses-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libdb++-dev libpcap-dev xz-utils git qrencode sqlite3 at mariadb-client rsyslog net-tools";
  601. apt-get install -y $debPacks --force-yes
  602. for debPack in ${debPacks}
  603. do
  604. packCheck=$(dpkg -l|grep ${debPack})
  605. if [ "$?" -ne "0" ] ;then
  606. apt-get install -y $debPack
  607. fi
  608. done
  609. if [ ! -d '/etc/letsencrypt' ];then
  610. mkdir -p /etc/letsencryp
  611. mkdir -p /var/spool/cron
  612. if [ ! -f '/var/spool/cron/crontabs/root' ];then
  613. echo '' > /var/spool/cron/crontabs/root
  614. chmod 600 /var/spool/cron/crontabs/root
  615. fi
  616. fi
  617. }
  618. Get_Versions(){
  619. redhat_version_file="/etc/redhat-release"
  620. deb_version_file="/etc/issue"
  621. if [[ $(grep Anolis /etc/os-release) ]] && [[ $(grep VERSION /etc/os-release|grep 8.8) ]];then
  622. if [ -f "/usr/bin/yum" ];then
  623. os_type="anolis"
  624. os_version="8"
  625. return
  626. fi
  627. fi
  628. if [ -f "/etc/os-release" ];then
  629. . /etc/os-release
  630. OS_V=${VERSION_ID%%.*}
  631. if [ "${ID}" == "opencloudos" ] && [[ "${OS_V}" =~ ^(9)$ ]];then
  632. os_type="opencloudos"
  633. os_version="9"
  634. pyenv_tt="true"
  635. elif { [ "${ID}" == "almalinux" ] || [ "${ID}" == "centos" ] || [ "${ID}" == "rocky" ]; } && [[ "${OS_V}" =~ ^(9)$ ]]; then
  636. os_type="el"
  637. os_version="9"
  638. pyenv_tt="true"
  639. fi
  640. if [ "${pyenv_tt}" ];then
  641. return
  642. fi
  643. fi
  644. if [ -f $redhat_version_file ];then
  645. os_type='el'
  646. is_aliyunos=$(cat $redhat_version_file|grep Aliyun)
  647. if [ "$is_aliyunos" != "" ];then
  648. return
  649. fi
  650. if [[ $(grep "Alibaba Cloud" /etc/redhat-release) ]] && [[ $(grep al8 /etc/os-release) ]];then
  651. os_type="ali-linux-"
  652. os_version="al8"
  653. return
  654. fi
  655. if [[ $(grep "TencentOS Server" /etc/redhat-release|grep 3.1) ]];then
  656. os_type="TencentOS-"
  657. os_version="3.1"
  658. return
  659. fi
  660. os_version=$(cat $redhat_version_file|grep CentOS|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]')
  661. if [ "${os_version}" = "5" ];then
  662. os_version=""
  663. fi
  664. if [ -z "${os_version}" ];then
  665. os_version=$(cat /etc/redhat-release |grep Stream|grep -oE 8)
  666. fi
  667. else
  668. os_type='ubuntu'
  669. os_version=$(cat $deb_version_file|grep Ubuntu|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]+')
  670. if [ "${os_version}" = "" ];then
  671. os_type='debian'
  672. os_version=$(cat $deb_version_file|grep Debian|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '[0-9]+')
  673. if [ "${os_version}" = "" ];then
  674. os_version=$(cat $deb_version_file|grep Debian|grep -Eo '[0-9]+')
  675. fi
  676. if [ "${os_version}" = "8" ];then
  677. os_version=""
  678. fi
  679. if [ "${is64bit}" = '32' ];then
  680. os_version=""
  681. fi
  682. else
  683. if [ "$os_version" = "14" ];then
  684. os_version=""
  685. fi
  686. if [ "$os_version" = "12" ];then
  687. os_version=""
  688. fi
  689. if [ "$os_version" = "19" ];then
  690. os_version=""
  691. fi
  692. if [ "$os_version" = "21" ];then
  693. os_version=""
  694. fi
  695. if [ "$os_version" = "20" ];then
  696. os_version2004=$(cat /etc/issue|grep 20.04)
  697. if [ -z "${os_version2004}" ];then
  698. os_version=""
  699. fi
  700. fi
  701. fi
  702. fi
  703. }
  704. Install_Python_Lib(){
  705. curl -Ss --connect-timeout 3 -m 60 $download_Url/install/pip_select.sh|bash
  706. pyenv_path="/www/server/panel"
  707. if [ -f $pyenv_path/pyenv/bin/python ];then
  708. is_ssl=$($python_bin -c "import ssl" 2>&1|grep cannot)
  709. $pyenv_path/pyenv/bin/python3.7 -V
  710. if [ $? -eq 0 ] && [ -z "${is_ssl}" ];then
  711. chmod -R 700 $pyenv_path/pyenv/bin
  712. is_package=$($python_bin -m psutil 2>&1|grep package)
  713. if [ "$is_package" = "" ];then
  714. wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip.txt -T 15
  715. $pyenv_path/pyenv/bin/pip install -U pip
  716. $pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
  717. $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
  718. fi
  719. source $pyenv_path/pyenv/bin/activate
  720. chmod -R 700 $pyenv_path/pyenv/bin
  721. return
  722. else
  723. rm -rf $pyenv_path/pyenv
  724. fi
  725. fi
  726. is_loongarch64=$(uname -a|grep loongarch64)
  727. if [ "$is_loongarch64" != "" ] && [ -f "/usr/bin/yum" ];then
  728. yumPacks="python3-devel python3-pip python3-psutil python3-gevent python3-pyOpenSSL python3-paramiko python3-flask python3-rsa python3-requests python3-six python3-websocket-client"
  729. yum install -y ${yumPacks}
  730. for yumPack in ${yumPacks}
  731. do
  732. rpmPack=$(rpm -q ${yumPack})
  733. packCheck=$(echo ${rpmPack}|grep not)
  734. if [ "${packCheck}" ]; then
  735. yum install ${yumPack} -y
  736. fi
  737. done
  738. pip3 install -U pip
  739. pip3 install Pillow psutil pyinotify pycryptodome upyun oss2 pymysql qrcode qiniu redis pymongo Cython configparser cos-python-sdk-v5 supervisor gevent-websocket pyopenssl
  740. pip3 install flask==1.1.4
  741. pip3 install Pillow -U
  742. pyenv_bin=/www/server/panel/pyenv/bin
  743. mkdir -p $pyenv_bin
  744. ln -sf /usr/local/bin/pip3 $pyenv_bin/pip
  745. ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3
  746. ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3.7
  747. if [ -f "/usr/bin/python3.7" ];then
  748. ln -sf /usr/bin/python3.7 $pyenv_bin/python
  749. ln -sf /usr/bin/python3.7 $pyenv_bin/python3
  750. ln -sf /usr/bin/python3.7 $pyenv_bin/python3.7
  751. elif [ -f "/usr/bin/python3.6" ]; then
  752. ln -sf /usr/bin/python3.6 $pyenv_bin/python
  753. ln -sf /usr/bin/python3.6 $pyenv_bin/python3
  754. ln -sf /usr/bin/python3.6 $pyenv_bin/python3.7
  755. fi
  756. echo > $pyenv_bin/activate
  757. return
  758. fi
  759. py_version="3.7.16"
  760. mkdir -p $pyenv_path
  761. echo "True" > /www/disk.pl
  762. if [ ! -w /www/disk.pl ];then
  763. Red_Error "ERROR: Install python env fielded." "ERROR: /www目录无法写入,请检查目录/用户/磁盘权限!"
  764. fi
  765. os_type='el'
  766. os_version='7'
  767. is_export_openssl=0
  768. Get_Versions
  769. echo "OS: $os_type - $os_version"
  770. is_aarch64=$(uname -a|grep aarch64)
  771. if [ "$is_aarch64" != "" ];then
  772. is64bit="aarch64"
  773. fi
  774. if [ -f "/www/server/panel/pymake.pl" ];then
  775. os_version=""
  776. rm -f /www/server/panel/pymake.pl
  777. fi
  778. echo "==============================================="
  779. echo "正在下载面板运行环境,请稍等..............."
  780. echo "==============================================="
  781. if [ "${os_version}" != "" ];then
  782. pyenv_file="/www/pyenv.tar.gz"
  783. wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 20
  784. if [ "$?" != "0" ];then
  785. get_node_url $download_Url
  786. wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 20
  787. fi
  788. tmp_size=$(du -b $pyenv_file|awk '{print $1}')
  789. if [ $tmp_size -lt 703460 ];then
  790. rm -f $pyenv_file
  791. echo "ERROR: Download python env fielded."
  792. else
  793. echo "Install python env..."
  794. tar zxvf $pyenv_file -C $pyenv_path/ > /dev/null
  795. chmod -R 700 $pyenv_path/pyenv/bin
  796. if [ ! -f $pyenv_path/pyenv/bin/python ];then
  797. rm -f $pyenv_file
  798. Red_Error "ERROR: Install python env fielded." "ERROR: 下载宝塔运行环境失败,请尝试重新安装!"
  799. fi
  800. $pyenv_path/pyenv/bin/python3.7 -V
  801. if [ $? -eq 0 ];then
  802. rm -f $pyenv_file
  803. ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
  804. ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
  805. source $pyenv_path/pyenv/bin/activate
  806. return
  807. else
  808. rm -f $pyenv_file
  809. rm -rf $pyenv_path/pyenv
  810. fi
  811. fi
  812. fi
  813. cd /www
  814. python_src='/www/python_src.tar.xz'
  815. python_src_path="/www/Python-${py_version}"
  816. wget -O $python_src $download_Url/src/Python-${py_version}.tar.xz -T 15
  817. tmp_size=$(du -b $python_src|awk '{print $1}')
  818. if [ $tmp_size -lt 10703460 ];then
  819. rm -f $python_src
  820. Red_Error "ERROR: Download python source code fielded." "ERROR: 下载宝塔运行环境失败,请尝试重新安装!"
  821. fi
  822. tar xvf $python_src
  823. rm -f $python_src
  824. cd $python_src_path
  825. ./configure --prefix=$pyenv_path/pyenv
  826. make -j$cpu_cpunt
  827. make install
  828. if [ ! -f $pyenv_path/pyenv/bin/python3.7 ];then
  829. rm -rf $python_src_path
  830. Red_Error "ERROR: Make python env fielded." "ERROR: 编译宝塔运行环境失败!"
  831. fi
  832. cd ~
  833. rm -rf $python_src_path
  834. wget -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -T 5
  835. wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip-3.7.16.txt -T 5
  836. ln -sf $pyenv_path/pyenv/bin/pip3.7 $pyenv_path/pyenv/bin/pip
  837. ln -sf $pyenv_path/pyenv/bin/python3.7 $pyenv_path/pyenv/bin/python
  838. ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
  839. ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
  840. chmod -R 700 $pyenv_path/pyenv/bin
  841. $pyenv_path/pyenv/bin/pip install -U pip
  842. $pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
  843. $pyenv_path/pyenv/bin/pip install -U wheel==0.34.2
  844. $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
  845. wget -O pip-packs.txt $download_Url/install/pyenv/pip-packs.txt
  846. echo "正在后台安装pip依赖请稍等.........."
  847. PIP_PACKS=$(cat pip-packs.txt)
  848. for P_PACK in ${PIP_PACKS};
  849. do
  850. btpip show ${P_PACK} > /dev/null 2>&1
  851. if [ "$?" == "1" ];then
  852. btpip install ${P_PACK}
  853. fi
  854. done
  855. rm -f pip-packs.txt
  856. source $pyenv_path/pyenv/bin/activate
  857. btpip install psutil
  858. btpip install gevent
  859. is_gevent=$($python_bin -m gevent 2>&1|grep -oE package)
  860. is_psutil=$($python_bin -m psutil 2>&1|grep -oE package)
  861. if [ "${is_gevent}" != "${is_psutil}" ];then
  862. Red_Error "ERROR: psutil/gevent install failed!"
  863. fi
  864. }
  865. Install_Bt(){
  866. if [ -f ${setup_path}/server/panel/data/port.pl ];then
  867. panelPort=$(cat ${setup_path}/server/panel/data/port.pl)
  868. fi
  869. if [ "${PANEL_PORT}" ];then
  870. panelPort=$PANEL_PORT
  871. fi
  872. mkdir -p ${setup_path}/server/panel/logs
  873. mkdir -p ${setup_path}/server/panel/vhost/apache
  874. mkdir -p ${setup_path}/server/panel/vhost/nginx
  875. mkdir -p ${setup_path}/server/panel/vhost/rewrite
  876. mkdir -p ${setup_path}/server/panel/install
  877. mkdir -p /www/server
  878. mkdir -p /www/wwwroot
  879. mkdir -p /www/wwwlogs
  880. mkdir -p /www/backup/database
  881. mkdir -p /www/backup/site
  882. if [ ! -d "/etc/init.d" ];then
  883. mkdir -p /etc/init.d
  884. fi
  885. if [ -f "/etc/init.d/bt" ]; then
  886. /etc/init.d/bt stop
  887. sleep 1
  888. fi
  889. wget -O /etc/init.d/bt ${download_Url}/install/src/bt6.init -T 15
  890. wget -O /www/server/panel/install/public.sh ${Btapi_Url}/install/public.sh -T 15
  891. echo "=============================================="
  892. echo "正在下载面板文件,请稍等..................."
  893. echo "=============================================="
  894. wget -O panel.zip ${Btapi_Url}/install/src/panel6.zip -T 15
  895. if [ -f "${setup_path}/server/panel/data/default.db" ];then
  896. if [ -d "/${setup_path}/server/panel/old_data" ];then
  897. rm -rf ${setup_path}/server/panel/old_data
  898. fi
  899. mkdir -p ${setup_path}/server/panel/old_data
  900. d_format=$(date +"%Y%m%d_%H%M%S")
  901. \cp -arf ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/data/default_backup_${d_format}.db
  902. mv -f ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/old_data/default.db
  903. mv -f ${setup_path}/server/panel/data/system.db ${setup_path}/server/panel/old_data/system.db
  904. mv -f ${setup_path}/server/panel/data/port.pl ${setup_path}/server/panel/old_data/port.pl
  905. mv -f ${setup_path}/server/panel/data/admin_path.pl ${setup_path}/server/panel/old_data/admin_path.pl
  906. if [ -d "${setup_path}/server/panel/data/db" ];then
  907. \cp -r ${setup_path}/server/panel/data/db ${setup_path}/server/panel/old_data/
  908. fi
  909. fi
  910. if [ ! -f "/usr/bin/unzip" ]; then
  911. if [ "${PM}" = "yum" ]; then
  912. yum install unzip -y
  913. elif [ "${PM}" = "apt-get" ]; then
  914. apt-get update
  915. apt-get install unzip -y 2>&1|tee /tmp/apt_install_log.log
  916. UNZIP_CHECK=$(which unzip)
  917. if [ "$?" != "0" ];then
  918. RECONFIGURE_CHECK=$(grep "dpkg --configure -a" /tmp/apt_install_log.log)
  919. if [ "${RECONFIGURE_CHECK}" ];then
  920. dpkg --configure -a
  921. fi
  922. APT_LOCK_CHECH=$(grep "/var/lib/dpkg/lock" /tmp/apt_install_log.log)
  923. if [ "${APT_LOCK_CHECH}" ];then
  924. pkill dpkg
  925. pkill apt-get
  926. pkill apt
  927. [ -e /var/lib/dpkg/lock-frontend ] && rm -f /var/lib/dpkg/lock-frontend
  928. [ -e /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock
  929. [ -e /var/lib/apt/lists/lock ] && rm -f /var/lib/apt/lists/lock
  930. [ -e /var/cache/apt/archives/lock ] && rm -f /var/cache/apt/archives/lock
  931. dpkg --configure -a
  932. fi
  933. sleep 5
  934. apt-get install unzip -y
  935. fi
  936. fi
  937. fi
  938. unzip -o panel.zip -d ${setup_path}/server/ > /dev/null
  939. if [ -d "${setup_path}/server/panel/old_data" ];then
  940. mv -f ${setup_path}/server/panel/old_data/default.db ${setup_path}/server/panel/data/default.db
  941. mv -f ${setup_path}/server/panel/old_data/system.db ${setup_path}/server/panel/data/system.db
  942. mv -f ${setup_path}/server/panel/old_data/port.pl ${setup_path}/server/panel/data/port.pl
  943. mv -f ${setup_path}/server/panel/old_data/admin_path.pl ${setup_path}/server/panel/data/admin_path.pl
  944. if [ -d "${setup_path}/server/panel/old_data/db" ];then
  945. \cp -r ${setup_path}/server/panel/old_data/db ${setup_path}/server/panel/data/
  946. fi
  947. if [ -d "/${setup_path}/server/panel/old_data" ];then
  948. rm -rf ${setup_path}/server/panel/old_data
  949. fi
  950. fi
  951. if [ ! -f ${setup_path}/server/panel/tools.py ] || [ ! -f ${setup_path}/server/panel/BT-Panel ];then
  952. ls -lh panel.zip
  953. Red_Error "ERROR: Failed to download, please try install again!" "ERROR: 下载宝塔失败,请尝试重新安装!"
  954. fi
  955. SYS_LOG_CHECK=$(grep ^weekly /etc/logrotate.conf)
  956. if [ "${SYS_LOG_CHECK}" ];then
  957. sed -i 's/rotate [0-9]*/rotate 8/g' /etc/logrotate.conf
  958. fi
  959. rm -f panel.zip
  960. rm -f ${setup_path}/server/panel/class/*.pyc
  961. rm -f ${setup_path}/server/panel/*.pyc
  962. chmod +x /etc/init.d/bt
  963. chmod -R 600 ${setup_path}/server/panel
  964. chmod -R +x ${setup_path}/server/panel/script
  965. ln -sf /etc/init.d/bt /usr/bin/bt
  966. echo "${panelPort}" > ${setup_path}/server/panel/data/port.pl
  967. wget -O /etc/init.d/bt ${download_Url}/install/src/bt7.init -T 15
  968. wget -O /www/server/panel/init.sh ${download_Url}/install/src/bt7.init -T 15
  969. wget -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softList.conf
  970. rm -f /www/server/panel/class/*.so
  971. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  972. echo "True" > /www/server/panel/data/not_workorder.pl
  973. fi
  974. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  975. echo "{\"uid\":1,\"username\":\"Administrator\",\"address\":\"127.0.0.1\",\"access_key\":\"test\",\"secret_key\":\"123456\",\"ukey\":\"123456\",\"state\":1}" > /www/server/panel/data/userInfo.json
  976. fi
  977. if [ ! -f /www/server/panel/data/panel_nps.pl ]; then
  978. echo "" > /www/server/panel/data/panel_nps.pl
  979. fi
  980. if [ ! -f /www/server/panel/data/btwaf_nps.pl ]; then
  981. echo "" > /www/server/panel/data/btwaf_nps.pl
  982. fi
  983. if [ ! -f /www/server/panel/data/tamper_proof_nps.pl ]; then
  984. echo "" > /www/server/panel/data/tamper_proof_nps.pl
  985. fi
  986. if [ ! -f /www/server/panel/data/total_nps.pl ]; then
  987. echo "" > /www/server/panel/data/total_nps.pl
  988. fi
  989. }
  990. Set_Bt_Panel(){
  991. Run_User="www"
  992. wwwUser=$(cat /etc/passwd|cut -d ":" -f 1|grep ^www$)
  993. if [ "${wwwUser}" != "www" ];then
  994. groupadd ${Run_User}
  995. useradd -s /sbin/nologin -g ${Run_User} ${Run_User}
  996. fi
  997. password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
  998. if [ "$PANEL_PASSWORD" ];then
  999. password=$PANEL_PASSWORD
  1000. fi
  1001. sleep 1
  1002. admin_auth="/www/server/panel/data/admin_path.pl"
  1003. if [ ! -f ${admin_auth} ];then
  1004. auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
  1005. echo "/${auth_path}" > ${admin_auth}
  1006. fi
  1007. if [ "${SAFE_PATH}" ];then
  1008. auth_path=$SAFE_PATH
  1009. echo "/${auth_path}" > ${admin_auth}
  1010. fi
  1011. chmod -R 700 $pyenv_path/pyenv/bin
  1012. if [ ! -f "/www/server/panel/pyenv/n.pl" ];then
  1013. btpip install docxtpl==0.16.7
  1014. /www/server/panel/pyenv/bin/pip3 install pymongo
  1015. /www/server/panel/pyenv/bin/pip3 install psycopg2-binary
  1016. /www/server/panel/pyenv/bin/pip3 install flask -U
  1017. /www/server/panel/pyenv/bin/pip3 install flask-sock
  1018. /www/server/panel/pyenv/bin/pip3 install -I gevent
  1019. btpip install simple-websocket==0.10.0
  1020. btpip install natsort
  1021. btpip uninstall enum34 -y
  1022. btpip install geoip2==4.7.0
  1023. btpip install brotli
  1024. btpip install PyMySQL
  1025. fi
  1026. auth_path=$(cat ${admin_auth})
  1027. cd ${setup_path}/server/panel/
  1028. /etc/init.d/bt start
  1029. $python_bin -m py_compile tools.py
  1030. $python_bin tools.py username
  1031. username=$($python_bin tools.py panel ${password})
  1032. if [ "$PANEL_USER" ];then
  1033. username=$PANEL_USER
  1034. fi
  1035. cd ~
  1036. echo "${password}" > ${setup_path}/server/panel/default.pl
  1037. chmod 600 ${setup_path}/server/panel/default.pl
  1038. sleep 3
  1039. if [ "$SET_SSL" == true ]; then
  1040. if [ ! -f "/www/server/panel/pyenv/n.pl" ];then
  1041. btpip install -I pyOpenSSl 2>/dev/null
  1042. fi
  1043. echo "========================================"
  1044. echo "正在开启面板SSL,请稍等............ "
  1045. echo "========================================"
  1046. SSL_STATUS=$(btpython /www/server/panel/tools.py ssl)
  1047. if [ "${SSL_STATUS}" == "0" ] ;then
  1048. echo -n " -4 " > /www/server/panel/data/v4.pl
  1049. btpython /www/server/panel/tools.py ssl
  1050. fi
  1051. echo "证书开启成功!"
  1052. echo "========================================"
  1053. fi
  1054. /etc/init.d/bt stop
  1055. sleep 5
  1056. /etc/init.d/bt start
  1057. sleep 5
  1058. isStart=$(ps aux |grep 'BT-Panel'|grep -v grep|awk '{print $2}')
  1059. LOCAL_CURL=$(curl 127.0.0.1:${panelPort}/login 2>&1 |grep -i html)
  1060. if [ -z "${isStart}" ];then
  1061. /etc/init.d/bt 22
  1062. cd /www/server/panel/pyenv/bin
  1063. touch t.pl
  1064. ls -al python3.7 python
  1065. lsattr python3.7 python
  1066. btpython /www/server/panel/BT-Panel
  1067. Red_Error "ERROR: The BT-Panel service startup failed." "ERROR: 宝塔启动失败"
  1068. fi
  1069. if [ "$PANEL_USER" ];then
  1070. cd ${setup_path}/server/panel/
  1071. btpython -c 'import tools;tools.set_panel_username("'$PANEL_USER'")'
  1072. cd ~
  1073. fi
  1074. if [ -f "/usr/bin/sqlite3" ] ;then
  1075. sqlite3 /www/server/panel/data/db/panel.db "UPDATE config SET status = '1' WHERE id = '1';" > /dev/null 2>&1
  1076. fi
  1077. }
  1078. Set_Firewall(){
  1079. sshPort=$(cat /etc/ssh/sshd_config | grep 'Port '|awk '{print $2}')
  1080. if [ "${PM}" = "apt-get" ]; then
  1081. apt-get install -y ufw
  1082. if [ -f "/usr/sbin/ufw" ];then
  1083. ufw allow 20/tcp
  1084. ufw allow 21/tcp
  1085. ufw allow 22/tcp
  1086. ufw allow 80/tcp
  1087. ufw allow 443/tcp
  1088. ufw allow 888/tcp
  1089. ufw allow ${panelPort}/tcp
  1090. ufw allow ${sshPort}/tcp
  1091. ufw allow 39000:40000/tcp
  1092. ufw_status=`ufw status`
  1093. echo y|ufw enable
  1094. ufw default deny
  1095. ufw reload
  1096. fi
  1097. else
  1098. if [ -f "/etc/init.d/iptables" ];then
  1099. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
  1100. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
  1101. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
  1102. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
  1103. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
  1104. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${panelPort} -j ACCEPT
  1105. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${sshPort} -j ACCEPT
  1106. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 39000:40000 -j ACCEPT
  1107. #iptables -I INPUT -p tcp -m state --state NEW -m udp --dport 39000:40000 -j ACCEPT
  1108. iptables -A INPUT -p icmp --icmp-type any -j ACCEPT
  1109. iptables -A INPUT -s localhost -d localhost -j ACCEPT
  1110. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  1111. iptables -P INPUT DROP
  1112. service iptables save
  1113. sed -i "s#IPTABLES_MODULES=\"\"#IPTABLES_MODULES=\"ip_conntrack_netbios_ns ip_conntrack_ftp ip_nat_ftp\"#" /etc/sysconfig/iptables-config
  1114. iptables_status=$(service iptables status | grep 'not running')
  1115. if [ "${iptables_status}" == '' ];then
  1116. service iptables restart
  1117. fi
  1118. else
  1119. AliyunCheck=$(cat /etc/redhat-release|grep "Aliyun Linux")
  1120. [ "${AliyunCheck}" ] && return
  1121. yum install firewalld -y
  1122. [ "${Centos8Check}" ] && yum reinstall python3-six -y
  1123. systemctl enable firewalld
  1124. systemctl start firewalld
  1125. firewall-cmd --set-default-zone=public > /dev/null 2>&1
  1126. firewall-cmd --permanent --zone=public --add-port=20/tcp > /dev/null 2>&1
  1127. firewall-cmd --permanent --zone=public --add-port=21/tcp > /dev/null 2>&1
  1128. firewall-cmd --permanent --zone=public --add-port=22/tcp > /dev/null 2>&1
  1129. firewall-cmd --permanent --zone=public --add-port=80/tcp > /dev/null 2>&1
  1130. firewall-cmd --permanent --zone=public --add-port=443/tcp > /dev/null 2>&1
  1131. firewall-cmd --permanent --zone=public --add-port=${panelPort}/tcp > /dev/null 2>&1
  1132. firewall-cmd --permanent --zone=public --add-port=${sshPort}/tcp > /dev/null 2>&1
  1133. firewall-cmd --permanent --zone=public --add-port=39000-40000/tcp > /dev/null 2>&1
  1134. #firewall-cmd --permanent --zone=public --add-port=39000-40000/udp > /dev/null 2>&1
  1135. firewall-cmd --reload
  1136. fi
  1137. fi
  1138. }
  1139. Get_Ip_Address(){
  1140. getIpAddress=""
  1141. getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
  1142. if [ -z "${getIpAddress}" ] || [ "${getIpAddress}" = "0.0.0.0" ]; then
  1143. isHosts=$(cat /etc/hosts|grep 'www.bt.cn')
  1144. if [ -z "${isHosts}" ];then
  1145. echo "" >> /etc/hosts
  1146. getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
  1147. if [ -z "${getIpAddress}" ];then
  1148. sed -i "/bt.cn/d" /etc/hosts
  1149. fi
  1150. fi
  1151. fi
  1152. CN_CHECK=$(curl -sS --connect-timeout 10 -m 10 http://www.example.com/api/isCN)
  1153. if [ "${CN_CHECK}" == "True" ];then
  1154. echo "True" > /www/server/panel/data/domestic_ip.pl
  1155. else
  1156. echo "True" > /www/server/panel/data/foreign_ip.pl
  1157. fi
  1158. ipv4Check=$($python_bin -c "import re; print(re.match('^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$','${getIpAddress}'))")
  1159. if [ "${ipv4Check}" == "None" ];then
  1160. ipv6Address=$(echo ${getIpAddress}|tr -d "[]")
  1161. ipv6Check=$($python_bin -c "import re; print(re.match('^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$','${ipv6Address}'))")
  1162. if [ "${ipv6Check}" == "None" ]; then
  1163. getIpAddress="SERVER_IP"
  1164. else
  1165. echo "True" > ${setup_path}/server/panel/data/ipv6.pl
  1166. sleep 1
  1167. /etc/init.d/bt restart
  1168. getIpAddress=$(echo "[$getIpAddress]")
  1169. fi
  1170. fi
  1171. if [ "${getIpAddress}" != "SERVER_IP" ];then
  1172. echo "${getIpAddress}" > ${setup_path}/server/panel/data/iplist.txt
  1173. fi
  1174. LOCAL_IP=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
  1175. }
  1176. Setup_Count(){
  1177. curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/SetupCount?type=Linux\&o=$1 > /dev/null 2>&1
  1178. if [ "$1" != "" ];then
  1179. echo $1 > /www/server/panel/data/o.pl
  1180. cd /www/server/panel
  1181. $python_bin tools.py o
  1182. fi
  1183. echo /www > /var/bt_setupPath.conf
  1184. }
  1185. Install_Main(){
  1186. Ready_Check
  1187. #Set_Ssl
  1188. startTime=`date +%s`
  1189. Lock_Clear
  1190. System_Check
  1191. Get_Pack_Manager
  1192. Set_Repo_Url
  1193. get_node_url
  1194. MEM_TOTAL=$(free -g|grep Mem|awk '{print $2}')
  1195. if [ "${MEM_TOTAL}" -le "1" ];then
  1196. Auto_Swap
  1197. fi
  1198. if [ "${PM}" = "yum" ]; then
  1199. Install_RPM_Pack
  1200. elif [ "${PM}" = "apt-get" ]; then
  1201. Install_Deb_Pack
  1202. fi
  1203. Install_Python_Lib
  1204. Install_Bt
  1205. Set_Bt_Panel
  1206. Service_Add
  1207. Set_Firewall
  1208. Get_Ip_Address
  1209. Setup_Count ${IDC_CODE}
  1210. Add_lib_Install
  1211. }
  1212. echo "
  1213. +----------------------------------------------------------------------
  1214. | Bt-WebPanel FOR CentOS/Ubuntu/Debian
  1215. +----------------------------------------------------------------------
  1216. | Copyright © 2015-2099 BT-SOFT(http://www.bt.cn) All rights reserved.
  1217. +----------------------------------------------------------------------
  1218. | The WebPanel URL will be http://SERVER_IP:${panelPort} when installed.
  1219. +----------------------------------------------------------------------
  1220. | 为了您的正常使用,请确保使用全新或纯净的系统安装宝塔面板,不支持已部署项目/环境的系统安装
  1221. +----------------------------------------------------------------------
  1222. "
  1223. while [ ${#} -gt 0 ]; do
  1224. case $1 in
  1225. -u|--user)
  1226. PANEL_USER=$2
  1227. shift 1
  1228. ;;
  1229. -p|--password)
  1230. PANEL_PASSWORD=$2
  1231. shift 1
  1232. ;;
  1233. -P|--port)
  1234. PANEL_PORT=$2
  1235. shift 1
  1236. ;;
  1237. --safe-path)
  1238. SAFE_PATH=$2
  1239. shift 1
  1240. ;;
  1241. --ssl-disable)
  1242. SSL_PL="disable"
  1243. ;;
  1244. -y)
  1245. go="y"
  1246. ;;
  1247. *)
  1248. IDC_CODE=$1
  1249. ;;
  1250. esac
  1251. shift 1
  1252. done
  1253. while [ "$go" != 'y' ] && [ "$go" != 'n' ]
  1254. do
  1255. read -p "Do you want to install Bt-Panel to the $setup_path directory now?(y/n): " go;
  1256. done
  1257. if [ "$go" == 'n' ];then
  1258. exit;
  1259. fi
  1260. if [ -f "/www/server/panel/BT-Panel" ];then
  1261. AAPANEL_CHECK=$(grep www.aapanel.com /www/server/panel/BT-Panel)
  1262. if [ "${AAPANEL_CHECK}" ];then
  1263. echo -e "----------------------------------------------------"
  1264. echo -e "检查已安装有aapanel,无法进行覆盖安装宝塔面板"
  1265. echo -e "如继续执行安装将移去aapanel面板数据(备份至/www/server/aapanel路径) 全新安装宝塔面板"
  1266. echo -e "aapanel is alreday installed,Can't install panel"
  1267. echo -e "is install Baota panel, aapanel data will be removed (backed up to /www/server/aapanel)"
  1268. echo -e "Beginning new Baota panel installation."
  1269. echo -e "----------------------------------------------------"
  1270. echo -e "已知风险/Enter yes to force installation"
  1271. read -p "输入yes开始安装: " yes;
  1272. if [ "$yes" != "yes" ];then
  1273. echo -e "------------"
  1274. echo "取消安装"
  1275. exit;
  1276. fi
  1277. bt stop
  1278. sleep 1
  1279. mv /www/server/panel /www/server/aapanel
  1280. fi
  1281. fi
  1282. ARCH_LINUX=$(cat /etc/os-release |grep "Arch Linux")
  1283. if [ "${ARCH_LINUX}" ] && [ -f "/usr/bin/pacman" ];then
  1284. pacman -Sy
  1285. pacman -S curl wget unzip firewalld openssl pkg-config make gcc cmake libxml2 libxslt libvpx gd libsodium oniguruma sqlite libzip autoconf inetutils sudo --noconfirm
  1286. fi
  1287. Install_Main
  1288. PANEL_SSL=$(cat /www/server/panel/data/ssl.pl 2> /dev/null)
  1289. if [ "${PANEL_SSL}" == "True" ];then
  1290. HTTP_S="https"
  1291. else
  1292. HTTP_S="http"
  1293. fi
  1294. echo > /www/server/panel/data/bind.pl
  1295. echo -e "=================================================================="
  1296. echo -e "\033[32mCongratulations! Installed successfully!\033[0m"
  1297. echo -e "========================面板账户登录信息=========================="
  1298. echo -e ""
  1299. echo -e " 【云服务器】请在安全组放行 $panelPort 端口"
  1300. echo -e " 外网面板地址: ${HTTP_S}://${getIpAddress}:${panelPort}${auth_path}"
  1301. echo -e " 内网面板地址: ${HTTP_S}://${LOCAL_IP}:${panelPort}${auth_path}"
  1302. echo -e " username: $username"
  1303. echo -e " password: $password"
  1304. echo -e ""
  1305. echo -e "=================================================================="
  1306. endTime=`date +%s`
  1307. ((outTime=($endTime-$startTime)/60))
  1308. if [ "${outTime}" -le "5" ];then
  1309. echo ${download_Url} > /www/server/panel/install/d_node.pl
  1310. fi
  1311. if [ "${outTime}" == "0" ];then
  1312. ((outTime=($endTime-$startTime)))
  1313. echo -e "Time consumed:\033[32m $outTime \033[0mseconds!"
  1314. else
  1315. echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
  1316. fi