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.

1437 lines
50 KiB

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