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.

1065 lines
35 KiB

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