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.

999 lines
33 KiB

3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years 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. Red_Error "抱歉, 当前面板版本不支持32位系统, 请使用64位系统或安装宝塔5.9!";
  17. fi
  18. Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
  19. if [ "${Centos6Check}" ];then
  20. echo "Centos6不支持安装宝塔面板,请更换Centos7/8安装宝塔面板"
  21. exit 1
  22. fi
  23. UbuntuCheck=$(cat /etc/issue|grep Ubuntu|awk '{print $2}'|cut -f 1 -d '.')
  24. if [ "${UbuntuCheck}" ] && [ "${UbuntuCheck}" -lt "16" ];then
  25. echo "Ubuntu ${UbuntuCheck}不支持安装宝塔面板,建议更换Ubuntu18/20安装宝塔面板"
  26. exit 1
  27. fi
  28. cd ~
  29. setup_path="/www"
  30. python_bin=$setup_path/server/panel/pyenv/bin/python
  31. cpu_cpunt=$(cat /proc/cpuinfo|grep processor|wc -l)
  32. # if [ "$1" ];then
  33. # IDC_CODE=$1
  34. # fi
  35. GetSysInfo(){
  36. if [ -s "/etc/redhat-release" ];then
  37. SYS_VERSION=$(cat /etc/redhat-release)
  38. elif [ -s "/etc/issue" ]; then
  39. SYS_VERSION=$(cat /etc/issue)
  40. fi
  41. SYS_INFO=$(uname -a)
  42. SYS_BIT=$(getconf LONG_BIT)
  43. MEM_TOTAL=$(free -m|grep Mem|awk '{print $2}')
  44. CPU_INFO=$(getconf _NPROCESSORS_ONLN)
  45. echo -e ${SYS_VERSION}
  46. echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO}
  47. echo -e ${SYS_INFO}
  48. if [ -z "${os_version}" ];then
  49. echo -e "============================================"
  50. echo -e "检测到为非常用系统安装,建议更换至Centos-7或Debian-10+或Ubuntu-20+系统安装宝塔面板"
  51. echo -e "详情请查看系统兼容表:https://docs.qq.com/sheet/DUm54VUtyTVNlc21H?tab=BB08J2"
  52. echo -e "特殊情况可通过以下联系方式寻求安装协助情况"
  53. fi
  54. is64bit=$(getconf LONG_BIT)
  55. if [ "${is64bit}" == '32' ];then
  56. echo -e "宝塔面板不支持32位系统进行安装,请使用64位系统/服务器架构进行安装宝塔"
  57. exit 1
  58. fi
  59. S390X_CHECK=$(uname -a|grep s390x)
  60. if [ "${S390X_CHECK}" ];then
  61. echo -e "宝塔面板不支持s390x架构进行安装,请使用64位系统/服务器架构进行安装宝塔"
  62. exit 1
  63. fi
  64. echo -e "============================================"
  65. echo -e "请截图以上报错信息发帖至论坛www.bt.cn/bbs求助"
  66. }
  67. Red_Error(){
  68. echo '=================================================';
  69. printf '\033[1;31;40m%b\033[0m\n' "$@";
  70. GetSysInfo
  71. exit 1;
  72. }
  73. Lock_Clear(){
  74. if [ -f "/etc/bt_crack.pl" ];then
  75. chattr -R -ia /www
  76. chattr -ia /etc/init.d/bt
  77. \cp -rpa /www/backup/panel/vhost/* /www/server/panel/vhost/
  78. mv /www/server/panel/BTPanel/__init__.bak /www/server/panel/BTPanel/__init__.py
  79. rm -f /etc/bt_crack.pl
  80. fi
  81. }
  82. Install_Check(){
  83. if [ "${INSTALL_FORCE}" ];then
  84. return
  85. fi
  86. echo -e "----------------------------------------------------"
  87. echo -e "检查已有其他Web/mysql环境,安装宝塔可能影响现有站点及数据"
  88. echo -e "Web/mysql service is alreday installed,Can't install panel"
  89. echo -e "----------------------------------------------------"
  90. echo -e "已知风险/Enter yes to force installation"
  91. read -p "输入yes强制安装: " yes;
  92. if [ "$yes" != "yes" ];then
  93. echo -e "------------"
  94. echo "取消安装"
  95. exit;
  96. fi
  97. INSTALL_FORCE="true"
  98. }
  99. System_Check(){
  100. MYSQLD_CHECK=$(ps -ef |grep mysqld|grep -v grep|grep -v /www/server/mysql)
  101. PHP_CHECK=$(ps -ef|grep php-fpm|grep master|grep -v /www/server/php)
  102. NGINX_CHECK=$(ps -ef|grep nginx|grep master|grep -v /www/server/nginx)
  103. HTTPD_CHECK=$(ps -ef |grep -E 'httpd|apache'|grep -v /www/server/apache|grep -v grep)
  104. if [ "${PHP_CHECK}" ] || [ "${MYSQLD_CHECK}" ] || [ "${NGINX_CHECK}" ] || [ "${HTTPD_CHECK}" ];then
  105. Install_Check
  106. fi
  107. }
  108. Set_Ssl(){
  109. echo -e ""
  110. echo -e "----------------------------------------------------------------------"
  111. echo -e "为了您的面板使用安全,建议您开启面板SSL,开启后请使用https访问宝塔面板"
  112. echo -e "输入y回车即开启面板SSL并进行下一步安装"
  113. echo -e "输入n回车跳过面板SSL配置,直接进行安装"
  114. echo -e "10秒后将跳过SSL配置,直接进行面板安装"
  115. echo -e "----------------------------------------------------------------------"
  116. echo -e ""
  117. read -t 10 -p "是否确定开启面板SSL ? (y/n): " yes
  118. if [ $? != 0 ];then
  119. SET_SSL=false
  120. else
  121. case "$yes" in
  122. y)
  123. SET_SSL=true
  124. ;;
  125. n)
  126. SET_SSL=false
  127. rm -f /www/server/panel/data/ssl.pl
  128. ;;
  129. *)
  130. Set_Ssl
  131. esac
  132. fi
  133. }
  134. Get_Pack_Manager(){
  135. if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
  136. PM="yum"
  137. elif [ -f "/usr/bin/apt-get" ] && [ -f "/usr/bin/dpkg" ]; then
  138. PM="apt-get"
  139. fi
  140. }
  141. Auto_Swap()
  142. {
  143. swap=$(free |grep Swap|awk '{print $2}')
  144. if [ "${swap}" -gt 1 ];then
  145. echo "Swap total sizse: $swap";
  146. return;
  147. fi
  148. if [ ! -d /www ];then
  149. mkdir /www
  150. fi
  151. swapFile="/www/swap"
  152. dd if=/dev/zero of=$swapFile bs=1M count=1025
  153. mkswap -f $swapFile
  154. swapon $swapFile
  155. echo "$swapFile swap swap defaults 0 0" >> /etc/fstab
  156. swap=`free |grep Swap|awk '{print $2}'`
  157. if [ $swap -gt 1 ];then
  158. echo "Swap total sizse: $swap";
  159. return;
  160. fi
  161. sed -i "/\/www\/swap/d" /etc/fstab
  162. rm -f $swapFile
  163. }
  164. Service_Add(){
  165. if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ]; then
  166. chkconfig --add bt
  167. chkconfig --level 2345 bt on
  168. Centos9Check=$(cat /etc/redhat-release |grep ' 9')
  169. if [ "${Centos9Check}" ];then
  170. wget -O /usr/lib/systemd/system/btpanel.service ${download_Url}/init/systemd/btpanel.service
  171. systemctl enable btpanel
  172. fi
  173. elif [ "${PM}" == "apt-get" ]; then
  174. update-rc.d bt defaults
  175. fi
  176. }
  177. Set_Centos_Repo(){
  178. HUAWEI_CHECK=$(cat /etc/motd |grep "Huawei Cloud")
  179. if [ "${HUAWEI_CHECK}" ] && [ "${is64bit}" == "64" ];then
  180. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  181. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
  182. sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  183. rm -f /etc/yum.repos.d/epel.repo
  184. rm -f /etc/yum.repos.d/epel-*
  185. fi
  186. ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
  187. if [ "${ALIYUN_CHECK}" ] && [ "${is64bit}" == "64" ] && [ ! -f "/etc/yum.repos.d/Centos-vault-8.5.2111.repo" ];then
  188. rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
  189. wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
  190. wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
  191. 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
  192. sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
  193. fi
  194. MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo |grep "[^#]mirror.centos.org")
  195. if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
  196. \cp -rpa /etc/yum.repos.d/ /etc/yumBak
  197. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
  198. sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
  199. fi
  200. }
  201. get_node_url(){
  202. if [ ! -f /bin/curl ];then
  203. if [ "${PM}" = "yum" ]; then
  204. yum install curl -y
  205. elif [ "${PM}" = "apt-get" ]; then
  206. apt-get install curl -y
  207. fi
  208. fi
  209. if [ -f "/www/node.pl" ];then
  210. download_Url=$(cat /www/node.pl)
  211. echo "Download node: $download_Url";
  212. echo '---------------------------------------------';
  213. return
  214. fi
  215. echo '---------------------------------------------';
  216. echo "Selected download node...";
  217. 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);
  218. if [ "$1" ];then
  219. nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
  220. fi
  221. tmp_file1=/dev/shm/net_test1.pl
  222. tmp_file2=/dev/shm/net_test2.pl
  223. [ -f "${tmp_file1}" ] && rm -f ${tmp_file1}
  224. [ -f "${tmp_file2}" ] && rm -f ${tmp_file2}
  225. touch $tmp_file1
  226. touch $tmp_file2
  227. for node in ${nodes[@]};
  228. do
  229. NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/net_test|xargs)
  230. RES=$(echo ${NODE_CHECK}|awk '{print $1}')
  231. NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $2}')
  232. TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $3 * 1000 - 500 }'|cut -d '.' -f 1)
  233. if [ "${NODE_STATUS}" == "200" ];then
  234. if [ $TIME_TOTAL -lt 100 ];then
  235. if [ $RES -ge 1500 ];then
  236. echo "$RES $node" >> $tmp_file1
  237. fi
  238. else
  239. if [ $RES -ge 1500 ];then
  240. echo "$TIME_TOTAL $node" >> $tmp_file2
  241. fi
  242. fi
  243. i=$(($i+1))
  244. if [ $TIME_TOTAL -lt 100 ];then
  245. if [ $RES -ge 3000 ];then
  246. break;
  247. fi
  248. fi
  249. fi
  250. done
  251. NODE_URL=$(cat $tmp_file1|sort -r -g -t " " -k 1|head -n 1|awk '{print $2}')
  252. if [ -z "$NODE_URL" ];then
  253. NODE_URL=$(cat $tmp_file2|sort -g -t " " -k 1|head -n 1|awk '{print $2}')
  254. if [ -z "$NODE_URL" ];then
  255. NODE_URL='https://download.bt.cn';
  256. fi
  257. fi
  258. rm -f $tmp_file1
  259. rm -f $tmp_file2
  260. download_Url=$NODE_URL
  261. echo "Download node: $download_Url";
  262. echo '---------------------------------------------';
  263. }
  264. Remove_Package(){
  265. local PackageNmae=$1
  266. if [ "${PM}" == "yum" ];then
  267. isPackage=$(rpm -q ${PackageNmae}|grep "not installed")
  268. if [ -z "${isPackage}" ];then
  269. yum remove ${PackageNmae} -y
  270. fi
  271. elif [ "${PM}" == "apt-get" ];then
  272. isPackage=$(dpkg -l|grep ${PackageNmae})
  273. if [ "${PackageNmae}" ];then
  274. apt-get remove ${PackageNmae} -y
  275. fi
  276. fi
  277. }
  278. Install_RPM_Pack(){
  279. yumPath=/etc/yum.conf
  280. Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
  281. if [ "${Centos8Check}" ];then
  282. Set_Centos_Repo
  283. fi
  284. isExc=$(cat $yumPath|grep httpd)
  285. if [ "$isExc" = "" ];then
  286. echo "exclude=httpd nginx php mysql mairadb python-psutil python2-psutil" >> $yumPath
  287. fi
  288. #SYS_TYPE=$(uname -a|grep x86_64)
  289. #yumBaseUrl=$(cat /etc/yum.repos.d/CentOS-Base.repo|grep baseurl=http|cut -d '=' -f 2|cut -d '$' -f 1|head -n 1)
  290. #[ "${yumBaseUrl}" ] && checkYumRepo=$(curl --connect-timeout 5 --head -s -o /dev/null -w %{http_code} ${yumBaseUrl})
  291. #if [ "${checkYumRepo}" != "200" ] && [ "${SYS_TYPE}" ];then
  292. # curl -Ss --connect-timeout 3 -m 60 http://download.bt.cn/install/yumRepo_select.sh|bash
  293. #fi
  294. #尝试同步时间(从bt.cn)
  295. echo 'Synchronizing system time...'
  296. getBtTime=$(curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/index/get_time)
  297. if [ "${getBtTime}" ];then
  298. date -s "$(date -d @$getBtTime +"%Y-%m-%d %H:%M:%S")"
  299. fi
  300. if [ -z "${Centos8Check}" ]; then
  301. yum install ntp -y
  302. rm -rf /etc/localtime
  303. ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  304. #尝试同步国际时间(从ntp服务器)
  305. ntpdate 0.asia.pool.ntp.org
  306. setenforce 0
  307. fi
  308. startTime=`date +%s`
  309. sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
  310. #yum remove -y python-requests python3-requests python-greenlet python3-greenlet
  311. 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"
  312. yum install -y ${yumPacks}
  313. for yumPack in ${yumPacks}
  314. do
  315. rpmPack=$(rpm -q ${yumPack})
  316. packCheck=$(echo ${rpmPack}|grep not)
  317. if [ "${packCheck}" ]; then
  318. yum install ${yumPack} -y
  319. fi
  320. done
  321. if [ -f "/usr/bin/dnf" ]; then
  322. dnf install -y redhat-rpm-config
  323. fi
  324. ALI_OS=$(cat /etc/redhat-release |grep "Alibaba Cloud Linux release 3")
  325. if [ -z "${ALI_OS}" ];then
  326. yum install epel-release -y
  327. fi
  328. }
  329. Install_Deb_Pack(){
  330. ln -sf bash /bin/sh
  331. UBUNTU_22=$(cat /etc/issue|grep "Ubuntu 22")
  332. if [ "${UBUNTU_22}" ];then
  333. apt-get remove needrestart -y
  334. fi
  335. ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
  336. if [ "${ALIYUN_CHECK}" ] && [ "${UBUNTU_22}" ];then
  337. apt-get remove libicu70 -y
  338. fi
  339. apt-get update -y
  340. apt-get install bash -y
  341. if [ -f "/usr/bin/bash" ];then
  342. ln -sf /usr/bin/bash /bin/sh
  343. fi
  344. apt-get install ruby -y
  345. apt-get install lsb-release -y
  346. #apt-get install ntp ntpdate -y
  347. #/etc/init.d/ntp stop
  348. #update-rc.d ntp remove
  349. #cat >>~/.profile<<EOF
  350. #TZ='Asia/Shanghai'; export TZ
  351. #EOF
  352. #rm -rf /etc/localtime
  353. #cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  354. #echo 'Synchronizing system time...'
  355. #ntpdate 0.asia.pool.ntp.org
  356. #apt-get upgrade -y
  357. LIBCURL_VER=$(dpkg -l|grep libcurl4|awk '{print $3}')
  358. if [ "${LIBCURL_VER}" == "7.68.0-1ubuntu2.8" ];then
  359. apt-get remove libcurl4 -y
  360. apt-get install curl -y
  361. fi
  362. 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";
  363. apt-get install -y $debPacks --force-yes
  364. for debPack in ${debPacks}
  365. do
  366. packCheck=$(dpkg -l|grep ${debPack})
  367. if [ "$?" -ne "0" ] ;then
  368. apt-get install -y $debPack
  369. fi
  370. done
  371. if [ ! -d '/etc/letsencrypt' ];then
  372. mkdir -p /etc/letsencryp
  373. mkdir -p /var/spool/cron
  374. if [ ! -f '/var/spool/cron/crontabs/root' ];then
  375. echo '' > /var/spool/cron/crontabs/root
  376. chmod 600 /var/spool/cron/crontabs/root
  377. fi
  378. fi
  379. }
  380. Get_Versions(){
  381. redhat_version_file="/etc/redhat-release"
  382. deb_version_file="/etc/issue"
  383. if [ -f $redhat_version_file ];then
  384. os_type='el'
  385. is_aliyunos=$(cat $redhat_version_file|grep Aliyun)
  386. if [ "$is_aliyunos" != "" ];then
  387. return
  388. fi
  389. os_version=$(cat $redhat_version_file|grep CentOS|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]')
  390. if [ "${os_version}" = "5" ];then
  391. os_version=""
  392. fi
  393. if [ -z "${os_version}" ];then
  394. os_version=$(cat /etc/redhat-release |grep Stream|grep -oE 8)
  395. fi
  396. else
  397. os_type='ubuntu'
  398. os_version=$(cat $deb_version_file|grep Ubuntu|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]+')
  399. if [ "${os_version}" = "" ];then
  400. os_type='debian'
  401. os_version=$(cat $deb_version_file|grep Debian|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '[0-9]+')
  402. if [ "${os_version}" = "" ];then
  403. os_version=$(cat $deb_version_file|grep Debian|grep -Eo '[0-9]+')
  404. fi
  405. if [ "${os_version}" = "8" ];then
  406. os_version=""
  407. fi
  408. if [ "${is64bit}" = '32' ];then
  409. os_version=""
  410. fi
  411. else
  412. if [ "$os_version" = "14" ];then
  413. os_version=""
  414. fi
  415. if [ "$os_version" = "12" ];then
  416. os_version=""
  417. fi
  418. if [ "$os_version" = "19" ];then
  419. os_version=""
  420. fi
  421. if [ "$os_version" = "21" ];then
  422. os_version=""
  423. fi
  424. if [ "$os_version" = "20" ];then
  425. os_version2004=$(cat /etc/issue|grep 20.04)
  426. if [ -z "${os_version2004}" ];then
  427. os_version=""
  428. fi
  429. fi
  430. fi
  431. fi
  432. }
  433. Install_Python_Lib(){
  434. curl -Ss --connect-timeout 3 -m 60 $download_Url/install/pip_select.sh|bash
  435. pyenv_path="/www/server/panel"
  436. if [ -f $pyenv_path/pyenv/bin/python ];then
  437. is_ssl=$($python_bin -c "import ssl" 2>&1|grep cannot)
  438. $pyenv_path/pyenv/bin/python3.7 -V
  439. if [ $? -eq 0 ] && [ -z "${is_ssl}" ];then
  440. chmod -R 700 $pyenv_path/pyenv/bin
  441. is_package=$($python_bin -m psutil 2>&1|grep package)
  442. if [ "$is_package" = "" ];then
  443. wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip.txt -T 5
  444. $pyenv_path/pyenv/bin/pip install -U pip
  445. $pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
  446. $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
  447. fi
  448. source $pyenv_path/pyenv/bin/activate
  449. chmod -R 700 $pyenv_path/pyenv/bin
  450. return
  451. else
  452. rm -rf $pyenv_path/pyenv
  453. fi
  454. fi
  455. is_loongarch64=$(uname -a|grep loongarch64)
  456. if [ "$is_loongarch64" != "" ] && [ -f "/usr/bin/yum" ];then
  457. yumPacks="python3-devel python3-pip python3-psutil python3-gevent python3-pyOpenSSL python3-paramiko python3-flask python3-rsa python3-requests python3-six python3-websocket-client"
  458. yum install -y ${yumPacks}
  459. for yumPack in ${yumPacks}
  460. do
  461. rpmPack=$(rpm -q ${yumPack})
  462. packCheck=$(echo ${rpmPack}|grep not)
  463. if [ "${packCheck}" ]; then
  464. yum install ${yumPack} -y
  465. fi
  466. done
  467. pip3 install -U pip
  468. pip3 install Pillow psutil pyinotify pycryptodome upyun oss2 pymysql qrcode qiniu redis pymongo Cython configparser cos-python-sdk-v5 supervisor gevent-websocket pyopenssl
  469. pip3 install flask==1.1.4
  470. pip3 install Pillow -U
  471. pyenv_bin=/www/server/panel/pyenv/bin
  472. mkdir -p $pyenv_bin
  473. ln -sf /usr/local/bin/pip3 $pyenv_bin/pip
  474. ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3
  475. ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3.7
  476. if [ -f "/usr/bin/python3.7" ];then
  477. ln -sf /usr/bin/python3.7 $pyenv_bin/python
  478. ln -sf /usr/bin/python3.7 $pyenv_bin/python3
  479. ln -sf /usr/bin/python3.7 $pyenv_bin/python3.7
  480. elif [ -f "/usr/bin/python3.6" ]; then
  481. ln -sf /usr/bin/python3.6 $pyenv_bin/python
  482. ln -sf /usr/bin/python3.6 $pyenv_bin/python3
  483. ln -sf /usr/bin/python3.6 $pyenv_bin/python3.7
  484. fi
  485. echo > $pyenv_bin/activate
  486. return
  487. fi
  488. py_version="3.7.8"
  489. mkdir -p $pyenv_path
  490. echo "True" > /www/disk.pl
  491. if [ ! -w /www/disk.pl ];then
  492. Red_Error "ERROR: Install python env fielded." "ERROR: /www目录无法写入,请检查目录/用户/磁盘权限!"
  493. fi
  494. os_type='el'
  495. os_version='7'
  496. is_export_openssl=0
  497. Get_Versions
  498. echo "OS: $os_type - $os_version"
  499. is_aarch64=$(uname -a|grep aarch64)
  500. if [ "$is_aarch64" != "" ];then
  501. is64bit="aarch64"
  502. fi
  503. if [ -f "/www/server/panel/pymake.pl" ];then
  504. os_version=""
  505. rm -f /www/server/panel/pymake.pl
  506. fi
  507. if [ "${os_version}" != "" ];then
  508. pyenv_file="/www/pyenv.tar.gz"
  509. wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 10
  510. if [ "$?" != "0" ];then
  511. get_node_url $download_Url
  512. wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 10
  513. fi
  514. tmp_size=$(du -b $pyenv_file|awk '{print $1}')
  515. if [ $tmp_size -lt 703460 ];then
  516. rm -f $pyenv_file
  517. echo "ERROR: Download python env fielded."
  518. else
  519. echo "Install python env..."
  520. tar zxvf $pyenv_file -C $pyenv_path/ > /dev/null
  521. chmod -R 700 $pyenv_path/pyenv/bin
  522. if [ ! -f $pyenv_path/pyenv/bin/python ];then
  523. rm -f $pyenv_file
  524. Red_Error "ERROR: Install python env fielded." "ERROR: 下载宝塔运行环境失败,请尝试重新安装!"
  525. fi
  526. $pyenv_path/pyenv/bin/python3.7 -V
  527. if [ $? -eq 0 ];then
  528. rm -f $pyenv_file
  529. ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
  530. ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
  531. source $pyenv_path/pyenv/bin/activate
  532. return
  533. else
  534. rm -f $pyenv_file
  535. rm -rf $pyenv_path/pyenv
  536. fi
  537. fi
  538. fi
  539. cd /www
  540. python_src='/www/python_src.tar.xz'
  541. python_src_path="/www/Python-${py_version}"
  542. wget -O $python_src $download_Url/src/Python-${py_version}.tar.xz -T 5
  543. tmp_size=$(du -b $python_src|awk '{print $1}')
  544. if [ $tmp_size -lt 10703460 ];then
  545. rm -f $python_src
  546. Red_Error "ERROR: Download python source code fielded." "ERROR: 下载宝塔运行环境失败,请尝试重新安装!"
  547. fi
  548. tar xvf $python_src
  549. rm -f $python_src
  550. cd $python_src_path
  551. ./configure --prefix=$pyenv_path/pyenv
  552. make -j$cpu_cpunt
  553. make install
  554. if [ ! -f $pyenv_path/pyenv/bin/python3.7 ];then
  555. rm -rf $python_src_path
  556. Red_Error "ERROR: Make python env fielded." "ERROR: 编译宝塔运行环境失败!"
  557. fi
  558. cd ~
  559. rm -rf $python_src_path
  560. wget -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -T 5
  561. wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip-3.7.8.txt -T 5
  562. ln -sf $pyenv_path/pyenv/bin/pip3.7 $pyenv_path/pyenv/bin/pip
  563. ln -sf $pyenv_path/pyenv/bin/python3.7 $pyenv_path/pyenv/bin/python
  564. ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
  565. ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
  566. chmod -R 700 $pyenv_path/pyenv/bin
  567. $pyenv_path/pyenv/bin/pip install -U pip
  568. $pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
  569. $pyenv_path/pyenv/bin/pip install -U wheel==0.34.2
  570. $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
  571. source $pyenv_path/pyenv/bin/activate
  572. is_gevent=$($python_bin -m gevent 2>&1|grep -oE package)
  573. is_psutil=$($python_bin -m psutil 2>&1|grep -oE package)
  574. if [ "${is_gevent}" != "${is_psutil}" ];then
  575. Red_Error "ERROR: psutil/gevent install failed!"
  576. fi
  577. }
  578. Install_Bt(){
  579. panelPort="8888"
  580. if [ -f ${setup_path}/server/panel/data/port.pl ];then
  581. panelPort=$(cat ${setup_path}/server/panel/data/port.pl)
  582. else
  583. panelPort=$(expr $RANDOM % 55535 + 10000)
  584. fi
  585. if [ "${PANEL_PORT}" ];then
  586. panelPort=$PANEL_PORT
  587. fi
  588. mkdir -p ${setup_path}/server/panel/logs
  589. mkdir -p ${setup_path}/server/panel/vhost/apache
  590. mkdir -p ${setup_path}/server/panel/vhost/nginx
  591. mkdir -p ${setup_path}/server/panel/vhost/rewrite
  592. mkdir -p ${setup_path}/server/panel/install
  593. mkdir -p /www/server
  594. mkdir -p /www/wwwroot
  595. mkdir -p /www/wwwlogs
  596. mkdir -p /www/backup/database
  597. mkdir -p /www/backup/site
  598. if [ ! -d "/etc/init.d" ];then
  599. mkdir -p /etc/init.d
  600. fi
  601. if [ -f "/etc/init.d/bt" ]; then
  602. /etc/init.d/bt stop
  603. sleep 1
  604. fi
  605. wget -O /etc/init.d/bt ${download_Url}/install/src/bt6.init -T 10
  606. wget -O /www/server/panel/install/public.sh ${Btapi_Url}/install/public.sh -T 10
  607. wget -O panel.zip ${Btapi_Url}/install/src/panel6.zip -T 10
  608. if [ -f "${setup_path}/server/panel/data/default.db" ];then
  609. if [ -d "/${setup_path}/server/panel/old_data" ];then
  610. rm -rf ${setup_path}/server/panel/old_data
  611. fi
  612. mkdir -p ${setup_path}/server/panel/old_data
  613. d_format=$(date +"%Y%m%d_%H%M%S")
  614. \cp -arf ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/data/default_backup_${d_format}.db
  615. mv -f ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/old_data/default.db
  616. mv -f ${setup_path}/server/panel/data/system.db ${setup_path}/server/panel/old_data/system.db
  617. mv -f ${setup_path}/server/panel/data/port.pl ${setup_path}/server/panel/old_data/port.pl
  618. mv -f ${setup_path}/server/panel/data/admin_path.pl ${setup_path}/server/panel/old_data/admin_path.pl
  619. fi
  620. if [ ! -f "/usr/bin/unzip" ]; then
  621. if [ "${PM}" = "yum" ]; then
  622. yum install unzip -y
  623. elif [ "${PM}" = "apt-get" ]; then
  624. apt-get update
  625. apt-get install unzip -y
  626. fi
  627. fi
  628. unzip -o panel.zip -d ${setup_path}/server/ > /dev/null
  629. if [ -d "${setup_path}/server/panel/old_data" ];then
  630. mv -f ${setup_path}/server/panel/old_data/default.db ${setup_path}/server/panel/data/default.db
  631. mv -f ${setup_path}/server/panel/old_data/system.db ${setup_path}/server/panel/data/system.db
  632. mv -f ${setup_path}/server/panel/old_data/port.pl ${setup_path}/server/panel/data/port.pl
  633. mv -f ${setup_path}/server/panel/old_data/admin_path.pl ${setup_path}/server/panel/data/admin_path.pl
  634. if [ -d "/${setup_path}/server/panel/old_data" ];then
  635. rm -rf ${setup_path}/server/panel/old_data
  636. fi
  637. fi
  638. if [ ! -f ${setup_path}/server/panel/tools.py ] || [ ! -f ${setup_path}/server/panel/BT-Panel ];then
  639. ls -lh panel.zip
  640. Red_Error "ERROR: Failed to download, please try install again!" "ERROR: 下载宝塔失败,请尝试重新安装!"
  641. fi
  642. rm -f panel.zip
  643. rm -f ${setup_path}/server/panel/class/*.pyc
  644. rm -f ${setup_path}/server/panel/*.pyc
  645. chmod +x /etc/init.d/bt
  646. chmod -R 600 ${setup_path}/server/panel
  647. chmod -R +x ${setup_path}/server/panel/script
  648. ln -sf /etc/init.d/bt /usr/bin/bt
  649. echo "${panelPort}" > ${setup_path}/server/panel/data/port.pl
  650. wget -O /etc/init.d/bt ${download_Url}/install/src/bt7.init -T 10
  651. wget -O /www/server/panel/init.sh ${download_Url}/install/src/bt7.init -T 10
  652. wget -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softList.conf
  653. rm -f /www/server/panel/class/*.so
  654. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  655. echo "True" > /www/server/panel/data/not_workorder.pl
  656. fi
  657. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  658. echo "{\"uid\":1,\"username\":\"Administrator\",\"address\":\"127.0.0.1\",\"serverid\":\"1\",\"access_key\":\"test\",\"secret_key\":\"123456\",\"ukey\":\"123456\",\"state\":1}" > /www/server/panel/data/userInfo.json
  659. fi
  660. }
  661. Set_Bt_Panel(){
  662. Run_User="www"
  663. wwwUser=$(cat /etc/passwd|cut -d ":" -f 1|grep ^www$)
  664. if [ "${wwwUser}" != "www" ];then
  665. groupadd ${Run_User}
  666. useradd -s /sbin/nologin -g ${Run_User} ${Run_User}
  667. fi
  668. password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
  669. if [ "$PANEL_PASSWORD" ];then
  670. password=$PANEL_PASSWORD
  671. fi
  672. sleep 1
  673. admin_auth="/www/server/panel/data/admin_path.pl"
  674. if [ "${SAFE_PATH}" ];then
  675. auth_path=$SAFE_PATH
  676. echo "/${auth_path}" > ${admin_auth}
  677. fi
  678. if [ ! -f ${admin_auth} ];then
  679. auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
  680. echo "/${auth_path}" > ${admin_auth}
  681. fi
  682. auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
  683. echo "/${auth_path}" > ${admin_auth}
  684. chmod -R 700 $pyenv_path/pyenv/bin
  685. /www/server/panel/pyenv/bin/pip3 install pymongo
  686. /www/server/panel/pyenv/bin/pip3 install psycopg2-binary
  687. /www/server/panel/pyenv/bin/pip3 install flask -U
  688. /www/server/panel/pyenv/bin/pip3 install flask-sock
  689. auth_path=$(cat ${admin_auth})
  690. cd ${setup_path}/server/panel/
  691. if [ "$SET_SSL" == true ]; then
  692. btpip install -I pyOpenSSl
  693. btpython /www/server/panel/tools.py ssl
  694. fi
  695. /etc/init.d/bt start
  696. $python_bin -m py_compile tools.py
  697. $python_bin tools.py username
  698. username=$($python_bin tools.py panel ${password})
  699. if [ "$PANEL_USER" ];then
  700. username=$PANEL_USER
  701. fi
  702. cd ~
  703. echo "${password}" > ${setup_path}/server/panel/default.pl
  704. chmod 600 ${setup_path}/server/panel/default.pl
  705. sleep 3
  706. /etc/init.d/bt restart
  707. sleep 3
  708. isStart=$(ps aux |grep 'BT-Panel'|grep -v grep|awk '{print $2}')
  709. LOCAL_CURL=$(curl 127.0.0.1:${panelPort}/login 2>&1 |grep -i html)
  710. if [ -z "${isStart}" ] && [ -z "${LOCAL_CURL}" ];then
  711. /etc/init.d/bt 22
  712. cd /www/server/panel/pyenv/bin
  713. touch t.pl
  714. ls -al python3.7 python
  715. lsattr python3.7 python
  716. Red_Error "ERROR: The BT-Panel service startup failed." "ERROR: 宝塔启动失败"
  717. fi
  718. if [ "$PANEL_USER" ];then
  719. cd ${setup_path}/server/panel/
  720. btpython -c 'import tools;tools.set_panel_username("'$PANEL_USER'")'
  721. cd ~
  722. fi
  723. }
  724. Set_Firewall(){
  725. sshPort=$(cat /etc/ssh/sshd_config | grep 'Port '|awk '{print $2}')
  726. if [ "${PM}" = "apt-get" ]; then
  727. apt-get install -y ufw
  728. if [ -f "/usr/sbin/ufw" ];then
  729. ufw allow 20/tcp
  730. ufw allow 21/tcp
  731. ufw allow 22/tcp
  732. ufw allow 80/tcp
  733. ufw allow 443/tcp
  734. ufw allow 888/tcp
  735. ufw allow ${panelPort}/tcp
  736. ufw allow ${sshPort}/tcp
  737. ufw allow 39000:40000/tcp
  738. ufw_status=`ufw status`
  739. echo y|ufw enable
  740. ufw default deny
  741. ufw reload
  742. fi
  743. else
  744. if [ -f "/etc/init.d/iptables" ];then
  745. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
  746. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
  747. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
  748. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
  749. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
  750. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${panelPort} -j ACCEPT
  751. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${sshPort} -j ACCEPT
  752. iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 39000:40000 -j ACCEPT
  753. #iptables -I INPUT -p tcp -m state --state NEW -m udp --dport 39000:40000 -j ACCEPT
  754. iptables -A INPUT -p icmp --icmp-type any -j ACCEPT
  755. iptables -A INPUT -s localhost -d localhost -j ACCEPT
  756. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  757. iptables -P INPUT DROP
  758. service iptables save
  759. sed -i "s#IPTABLES_MODULES=\"\"#IPTABLES_MODULES=\"ip_conntrack_netbios_ns ip_conntrack_ftp ip_nat_ftp\"#" /etc/sysconfig/iptables-config
  760. iptables_status=$(service iptables status | grep 'not running')
  761. if [ "${iptables_status}" == '' ];then
  762. service iptables restart
  763. fi
  764. else
  765. AliyunCheck=$(cat /etc/redhat-release|grep "Aliyun Linux")
  766. [ "${AliyunCheck}" ] && return
  767. yum install firewalld -y
  768. [ "${Centos8Check}" ] && yum reinstall python3-six -y
  769. systemctl enable firewalld
  770. systemctl start firewalld
  771. firewall-cmd --set-default-zone=public > /dev/null 2>&1
  772. firewall-cmd --permanent --zone=public --add-port=20/tcp > /dev/null 2>&1
  773. firewall-cmd --permanent --zone=public --add-port=21/tcp > /dev/null 2>&1
  774. firewall-cmd --permanent --zone=public --add-port=22/tcp > /dev/null 2>&1
  775. firewall-cmd --permanent --zone=public --add-port=80/tcp > /dev/null 2>&1
  776. firewall-cmd --permanent --zone=public --add-port=443/tcp > /dev/null 2>&1
  777. firewall-cmd --permanent --zone=public --add-port=${panelPort}/tcp > /dev/null 2>&1
  778. firewall-cmd --permanent --zone=public --add-port=${sshPort}/tcp > /dev/null 2>&1
  779. firewall-cmd --permanent --zone=public --add-port=39000-40000/tcp > /dev/null 2>&1
  780. #firewall-cmd --permanent --zone=public --add-port=39000-40000/udp > /dev/null 2>&1
  781. firewall-cmd --reload
  782. fi
  783. fi
  784. }
  785. Get_Ip_Address(){
  786. getIpAddress=""
  787. getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
  788. if [ -z "${getIpAddress}" ] || [ "${getIpAddress}" = "0.0.0.0" ]; then
  789. isHosts=$(cat /etc/hosts|grep 'www.bt.cn')
  790. if [ -z "${isHosts}" ];then
  791. echo "" >> /etc/hosts
  792. getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
  793. if [ -z "${getIpAddress}" ];then
  794. sed -i "/bt.cn/d" /etc/hosts
  795. fi
  796. fi
  797. fi
  798. ipv4Check=$($python_bin -c "import re; print(re.match('^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$','${getIpAddress}'))")
  799. if [ "${ipv4Check}" == "None" ];then
  800. ipv6Address=$(echo ${getIpAddress}|tr -d "[]")
  801. ipv6Check=$($python_bin -c "import re; print(re.match('^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$','${ipv6Address}'))")
  802. if [ "${ipv6Check}" == "None" ]; then
  803. getIpAddress="SERVER_IP"
  804. else
  805. echo "True" > ${setup_path}/server/panel/data/ipv6.pl
  806. sleep 1
  807. /etc/init.d/bt restart
  808. fi
  809. fi
  810. if [ "${getIpAddress}" != "SERVER_IP" ];then
  811. echo "${getIpAddress}" > ${setup_path}/server/panel/data/iplist.txt
  812. fi
  813. 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)
  814. }
  815. Setup_Count(){
  816. curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/SetupCount?type=Linux\&o=$1 > /dev/null 2>&1
  817. if [ "$1" != "" ];then
  818. echo $1 > /www/server/panel/data/o.pl
  819. cd /www/server/panel
  820. $python_bin tools.py o
  821. fi
  822. echo /www > /var/bt_setupPath.conf
  823. }
  824. Install_Main(){
  825. #Set_Ssl
  826. startTime=`date +%s`
  827. Lock_Clear
  828. System_Check
  829. Get_Pack_Manager
  830. get_node_url
  831. MEM_TOTAL=$(free -g|grep Mem|awk '{print $2}')
  832. if [ "${MEM_TOTAL}" -le "1" ];then
  833. Auto_Swap
  834. fi
  835. if [ "${PM}" = "yum" ]; then
  836. Install_RPM_Pack
  837. elif [ "${PM}" = "apt-get" ]; then
  838. Install_Deb_Pack
  839. fi
  840. Install_Python_Lib
  841. Install_Bt
  842. Set_Bt_Panel
  843. Service_Add
  844. Set_Firewall
  845. Get_Ip_Address
  846. Setup_Count ${IDC_CODE}
  847. }
  848. echo "
  849. +----------------------------------------------------------------------
  850. | Bt-WebPanel FOR CentOS/Ubuntu/Debian
  851. +----------------------------------------------------------------------
  852. | Copyright © 2015-2099 BT-SOFT(http://www.bt.cn) All rights reserved.
  853. +----------------------------------------------------------------------
  854. | The WebPanel URL will be http://SERVER_IP:8888 when installed.
  855. +----------------------------------------------------------------------
  856. | 为了您的正常使用,请确保使用全新或纯净的系统安装宝塔面板,不支持已部署项目/环境的系统安装
  857. +----------------------------------------------------------------------
  858. "
  859. while [ ${#} -gt 0 ]; do
  860. case $1 in
  861. -u|--user)
  862. PANEL_USER=$2
  863. shift 1
  864. ;;
  865. -p|--password)
  866. PANEL_PASSWORD=$2
  867. shift 1
  868. ;;
  869. -P|--port)
  870. PANEL_PORT=$2
  871. shift 1
  872. ;;
  873. --safe-path)
  874. SAFE_PATH=$2
  875. shift 1
  876. ;;
  877. -y)
  878. go="y"
  879. ;;
  880. *)
  881. IDC_CODE=$1
  882. ;;
  883. esac
  884. shift 1
  885. done
  886. while [ "$go" != 'y' ] && [ "$go" != 'n' ]
  887. do
  888. read -p "Do you want to install Bt-Panel to the $setup_path directory now?(y/n): " go;
  889. done
  890. if [ "$go" == 'n' ];then
  891. exit;
  892. fi
  893. ARCH_LINUX=$(cat /etc/os-release |grep "Arch Linux")
  894. if [ "${ARCH_LINUX}" ] && [ -f "/usr/bin/pacman" ];then
  895. pacman -Sy
  896. pacman -S curl wget unzip firewalld openssl pkg-config make gcc cmake libxml2 libxslt libvpx gd libsodium oniguruma sqlite libzip autoconf inetutils sudo --noconfirm
  897. fi
  898. Install_Main
  899. PANEL_SSL=$(cat /www/server/panel/data/ssl.pl 2> /dev/null)
  900. if [ "${PANEL_SSL}" == "True" ];then
  901. HTTP_S="https"
  902. else
  903. HTTP_S="http"
  904. fi
  905. echo > /www/server/panel/data/bind.pl
  906. echo -e "=================================================================="
  907. echo -e "\033[32mCongratulations! Installed successfully!\033[0m"
  908. echo -e "=================================================================="
  909. echo "外网面板地址: ${HTTP_S}://${getIpAddress}:${panelPort}${auth_path}"
  910. echo "内网面板地址: ${HTTP_S}://${LOCAL_IP}:${panelPort}${auth_path}"
  911. echo -e "username: $username"
  912. echo -e "password: $password"
  913. echo -e "\033[33mIf you cannot access the panel,\033[0m"
  914. echo -e "\033[33mrelease the following panel port [${panelPort}] in the security group\033[0m"
  915. echo -e "\033[33m若无法访问面板,请检查防火墙/安全组是否有放行面板[${panelPort}]端口\033[0m"
  916. if [ "${HTTP_S}" == "https" ];then
  917. echo -e "\033[33m因已开启面板自签证书,访问面板会提示不匹配证书,请参考以下链接配置证书\033[0m"
  918. echo -e "\033[33mhttps://www.bt.cn/bbs/thread-105443-1-1.html\033[0m"
  919. fi
  920. echo -e "=================================================================="
  921. endTime=`date +%s`
  922. ((outTime=($endTime-$startTime)/60))
  923. echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"