[
  {
    "path": "README.md",
    "content": "# btpanel-v7.7.0\nbtpanel-v7.7.0-backup  官方原版v7.7.0版本面板备份\n\n**Centos/Ubuntu/Debian安装命令 独立运行环境（py3.7）：**\n\n```Bash\ncurl -sSO https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/install_panel.sh && bash install_panel.sh\n```\n\n跳过登录框，以及破解插件等请自行搜索\n\n&nbsp;\n\n**如果遇到重启后宝塔乱码 请DD最新版Debian系统然后修改语言区域：**\n\n\n```Bash\nlocalectl set-locale LANG=en_US.UTF-8\nnano /etc/default/locale\n```\n\n```Bash\nLANG=\"en_US.UTF-8\"\nLC_ALL=\"en_US.UTF-8\"\n```\n\n修改后保存文件，重启VPS即可。\n"
  },
  {
    "path": "api/panel/get_version",
    "content": "7.7.0\n"
  },
  {
    "path": "install/conf/softList.conf",
    "content": "[{\r\n\t\t\"name\": \"Nginx\",\r\n\t\t\"versions\": [{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"1.20\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"1.21\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"1.19\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"1.18\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"-Tengine2.2\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"openresty\"\r\n\t\t}],\r\n\t\t\"type\": \"Web服务器\",\r\n\t\t\"msg\": \"Nginx是一款轻量级的Web服务器!\",\r\n\t\t\"shell\": \"nginx.sh\",\r\n\t\t\"check\": \"server/nginx/sbin/nginx\"\r\n\t},\r\n\t{\r\n\t\t\"name\": \"Apache\",\r\n\t\t\"versions\": [{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"2.4\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"2.2\"\r\n\t\t}],\r\n\t\t\"type\": \"Web服务器\",\r\n\t\t\"msg\": \"Apache是世界使用排名第一的Web服务器软件。\",\r\n\t\t\"shell\": \"httpd.sh\",\r\n\t\t\"check\": \"server/apache/bin/httpd\"\r\n\t},\r\n\t{\r\n\t\t\"name\": \"MySQL\",\r\n\t\t\"versions\": [{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.1\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.5\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.6\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.7\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"8.0\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"AliSQL\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"mariadb_10.0\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"mariadb_10.1\"\r\n\t\t}],\r\n\t\t\"type\": \"数据库\",\r\n\t\t\"msg\": \"推荐安装!\",\r\n\t\t\"shell\": \"mysql.sh\",\r\n\t\t\"check\": \"server/mysql/bin/mysql\"\r\n\t},\r\n\t{\r\n\t\t\"name\": \"Pure-Ftpd\",\r\n\t\t\"versions\": [{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"1.0.49\"\r\n\t\t}],\r\n\t\t\"type\": \"FTP服务器\",\r\n\t\t\"msg\": \"PureFTPd是一款专注于程序健壮和软件安全的免费FTP服务器软件\",\r\n\t\t\"shell\": \"pure-ftpd.sh\",\r\n\t\t\"check\": \"server/pure-ftpd/bin/pure-pw\"\r\n\t},\r\n\t{\r\n\t\t\"name\": \"PHP\",\r\n\t\t\"versions\": [{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.2\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.3\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.4\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.5\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.6\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"7.0\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"7.1\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"7.2\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"7.3\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"7.4\"\r\n\t\t},{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"8.0\"\r\n\t\t}],\r\n\t\t\"type\": \"语言解释器\",\r\n\t\t\"msg\": \"若非必要，请安装更新的版本!\",\r\n\t\t\"shell\": \"php.sh\",\r\n\t\t\"check\": \"server/php/VERSION/bin/php\"\r\n\t},\r\n\t{\r\n\t\t\"name\": \"Tomcat\",\r\n\t\t\"versions\": [{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"7\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"8\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"9\"\r\n\t\t}],\r\n\t\t\"type\": \"语言解释器\",\r\n\t\t\"msg\": \"java-ee解释器\",\r\n\t\t\"shell\": \"tomcat.sh\",\r\n\t\t\"check\": \"server/tomcat/bin/catalina.sh\"\r\n\t},\r\n\t{\r\n\t\t\"name\": \"phpMyAdmin\",\r\n\t\t\"versions\": [{\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"4.0\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"4.4\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"4.7\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"4.9\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"4.8\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.0\"\r\n\t\t}, {\r\n\t\t\t\"status\": false,\r\n\t\t\t\"version\": \"5.1\"\r\n\t\t}],\r\n\t\t\"type\": \"数据库工具\",\r\n\t\t\"msg\": \"Web端MySQL管理工具\",\r\n\t\t\"shell\": \"phpmyadmin.sh\",\r\n\t\t\"check\": \"server/phpmyadmin/version.pl\"\r\n\t}\r\n]"
  },
  {
    "path": "install/install_panel.sh",
    "content": "#!/bin/bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\nLANG=en_US.UTF-8\n\nif [ $(whoami) != \"root\" ];then\n\techo \"请使用root权限执行宝塔安装命令！\"\n\texit 1;\nfi\n\nis64bit=$(getconf LONG_BIT)\nif [ \"${is64bit}\" != '64' ];then\n\tRed_Error \"抱歉, 当前面板版本不支持32位系统, 请使用64位系统或安装宝塔5.9!\";\nfi\n\nCentos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')\nif [ \"${Centos6Check}\" ];then\n\techo \"Centos6不支持安装宝塔面板，请更换Centos7/8安装宝塔面板\"\n\texit 1\nfi \n\nUbuntuCheck=$(cat /etc/issue|grep Ubuntu|awk '{print $2}'|cut -f 1 -d '.')\nif [ \"${UbuntuCheck}\" -lt \"16\" ];then\n\techo \"Ubuntu ${UbuntuCheck}不支持安装宝塔面板，建议更换Ubuntu18/20安装宝塔面板\"\n\texit 1\nfi\n\ncd ~\nsetup_path=\"/www\"\npython_bin=$setup_path/server/panel/pyenv/bin/python\ncpu_cpunt=$(cat /proc/cpuinfo|grep processor|wc -l)\n\nif [ \"$1\" ];then\n\tIDC_CODE=$1\nfi\n\nGetSysInfo(){\n\tif [ -s \"/etc/redhat-release\" ];then\n\t\tSYS_VERSION=$(cat /etc/redhat-release)\n\telif [ -s \"/etc/issue\" ]; then\n\t\tSYS_VERSION=$(cat /etc/issue)\n\tfi\n\tSYS_INFO=$(uname -a)\n\tSYS_BIT=$(getconf LONG_BIT)\n\tMEM_TOTAL=$(free -m|grep Mem|awk '{print $2}')\n\tCPU_INFO=$(getconf _NPROCESSORS_ONLN)\n\n\techo -e ${SYS_VERSION}\n\techo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO}\n\techo -e ${SYS_INFO}\n\techo -e \"请截图以上报错信息发帖至论坛www.bt.cn/bbs求助\"\n}\nRed_Error(){\n\techo '=================================================';\n\tprintf '\\033[1;31;40m%b\\033[0m\\n' \"$@\";\n\tGetSysInfo\n\texit 1;\n}\nLock_Clear(){\n\tif [ -f \"/etc/bt_crack.pl\" ];then\n\t\tchattr -R -ia /www\n\t\tchattr -ia /etc/init.d/bt\n\t\t\\cp -rpa /www/backup/panel/vhost/* /www/server/panel/vhost/\n\t\tmv /www/server/panel/BTPanel/__init__.bak /www/server/panel/BTPanel/__init__.py\n\t\trm -f /etc/bt_crack.pl\n\tfi\n}\nInstall_Check(){\n\tif [ \"${INSTALL_FORCE}\" ];then\n\t\treturn\n\tfi\n\techo -e \"----------------------------------------------------\"\n\techo -e \"检查已有其他Web/mysql环境，安装宝塔可能影响现有站点及数据\"\n\techo -e \"Web/mysql service is alreday installed,Can't install panel\"\n\techo -e \"----------------------------------------------------\"\n\techo -e \"已知风险/Enter yes to force installation\"\n\tread -p \"输入yes强制安装: \" yes;\n\tif [ \"$yes\" != \"yes\" ];then\n\t\techo -e \"------------\"\n\t\techo \"取消安装\"\n\t\texit;\n\tfi\n\tINSTALL_FORCE=\"true\"\n}\nSystem_Check(){\n\tMYSQLD_CHECK=$(ps -ef |grep mysqld|grep -v grep|grep -v /www/server/mysql)\n\tPHP_CHECK=$(ps -ef|grep php-fpm|grep master|grep -v /www/server/php)\n\tNGINX_CHECK=$(ps -ef|grep nginx|grep master|grep -v /www/server/nginx)\n\tHTTPD_CHECK=$(ps -ef |grep -E 'httpd|apache'|grep -v /www/server/apache|grep -v grep)\n\tif [ \"${PHP_CHECK}\" ] || [ \"${MYSQLD_CHECK}\" ] || [ \"${NGINX_CHECK}\" ] || [ \"${HTTPD_CHECK}\" ];then\n\t\tInstall_Check\n\tfi\n}\nGet_Pack_Manager(){\n\tif [ -f \"/usr/bin/yum\" ] && [ -d \"/etc/yum.repos.d\" ]; then\n\t\tPM=\"yum\"\n\telif [ -f \"/usr/bin/apt-get\" ] && [ -f \"/usr/bin/dpkg\" ]; then\n\t\tPM=\"apt-get\"\t\t\n\tfi\n}\nAuto_Swap()\n{\n\tswap=$(free |grep Swap|awk '{print $2}')\n\tif [ \"${swap}\" -gt 1 ];then\n\t\techo \"Swap total sizse: $swap\";\n\t\treturn;\n\tfi\n\tif [ ! -d /www ];then\n\t\tmkdir /www\n\tfi\n\tswapFile=\"/www/swap\"\n\tdd if=/dev/zero of=$swapFile bs=1M count=1025\n\tmkswap -f $swapFile\n\tswapon $swapFile\n\techo \"$swapFile    swap    swap    defaults    0 0\" >> /etc/fstab\n\tswap=`free |grep Swap|awk '{print $2}'`\n\tif [ $swap -gt 1 ];then\n\t\techo \"Swap total sizse: $swap\";\n\t\treturn;\n\tfi\n\t\n\tsed -i \"/\\/www\\/swap/d\" /etc/fstab\n\trm -f $swapFile\n}\nService_Add(){\n\tif [ \"${PM}\" == \"yum\" ] || [ \"${PM}\" == \"dnf\" ]; then\n\t\tchkconfig --add bt\n\t\tchkconfig --level 2345 bt on\n\telif [ \"${PM}\" == \"apt-get\" ]; then\n\t\tupdate-rc.d bt defaults\n\tfi \n}\n\nget_node_url(){\n\tif [ ! -f /bin/curl ];then\n\t\tif [ \"${PM}\" = \"yum\" ]; then\n\t\t\tyum install curl -y\n\t\telif [ \"${PM}\" = \"apt-get\" ]; then\n\t\t\tapt-get install curl -y\n\t\tfi\n\tfi\n\n\tif [ -f \"/www/node.pl\" ];then\n\t\tdownload_Url=$(cat /www/node.pl)\n\t\techo \"Download node: $download_Url\";\n\t\techo '---------------------------------------------';\n\t\treturn\n\tfi\n\t\n\techo '---------------------------------------------';\n\techo \"Selected download node...\";\n\tnodes=(http://dg2.bt.cn http://dg1.bt.cn http://125.90.93.52:5880 http://36.133.1.8:5880 http://123.129.198.197 http://38.34.185.130 http://116.213.43.206:5880 http://128.1.164.196);\n\ttmp_file1=/dev/shm/net_test1.pl\n\ttmp_file2=/dev/shm/net_test2.pl\n\t[ -f \"${tmp_file1}\" ] && rm -f ${tmp_file1}\n\t[ -f \"${tmp_file2}\" ] && rm -f ${tmp_file2}\n\ttouch $tmp_file1\n\ttouch $tmp_file2\n\tfor node in ${nodes[@]};\n\tdo\n\t\tNODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w \"%{http_code} %{time_total}\" ${node}/net_test|xargs)\n\t\tRES=$(echo ${NODE_CHECK}|awk '{print $1}')\n\t\tNODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $2}')\n\t\tTIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $3 * 1000 - 500 }'|cut -d '.' -f 1)\n\t\tif [ \"${NODE_STATUS}\" == \"200\" ];then\n\t\t\tif [ $TIME_TOTAL -lt 100 ];then\n\t\t\t\tif [ $RES -ge 1500 ];then\n\t\t\t\t\techo \"$RES $node\" >> $tmp_file1\n\t\t\t\tfi\n\t\t\telse\n\t\t\t\tif [ $RES -ge 1500 ];then\n\t\t\t\t\techo \"$TIME_TOTAL $node\" >> $tmp_file2\n\t\t\t\tfi\n\t\t\tfi\n\n\t\t\ti=$(($i+1))\n\t\t\tif [ $TIME_TOTAL -lt 100 ];then\n\t\t\t\tif [ $RES -ge 3000 ];then\n\t\t\t\t\tbreak;\n\t\t\t\tfi\n\t\t\tfi\t\n\t\tfi\n\tdone\n\n\tNODE_URL=$(cat $tmp_file1|sort -r -g -t \" \" -k 1|head -n 1|awk '{print $2}')\n\tif [ -z \"$NODE_URL\" ];then\n\t\tNODE_URL=$(cat $tmp_file2|sort -g -t \" \" -k 1|head -n 1|awk '{print $2}')\n\t\tif [ -z \"$NODE_URL\" ];then\n\t\t\tNODE_URL='http://download.bt.cn';\n\t\tfi\n\tfi\n\trm -f $tmp_file1\n\trm -f $tmp_file2\n\tdownload_Url=$NODE_URL\n\techo \"Download node: $download_Url\";\n\techo '---------------------------------------------';\n}\nRemove_Package(){\n\tlocal PackageNmae=$1\n\tif [ \"${PM}\" == \"yum\" ];then\n\t\tisPackage=$(rpm -q ${PackageNmae}|grep \"not installed\")\n\t\tif [ -z \"${isPackage}\" ];then\n\t\t\tyum remove ${PackageNmae} -y\n\t\tfi \n\telif [ \"${PM}\" == \"apt-get\" ];then\n\t\tisPackage=$(dpkg -l|grep ${PackageNmae})\n\t\tif [ \"${PackageNmae}\" ];then\n\t\t\tapt-get remove ${PackageNmae} -y\n\t\tfi\n\tfi\n}\nInstall_RPM_Pack(){\n\tyumPath=/etc/yum.conf\n\tCentos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')\n\tisExc=$(cat $yumPath|grep httpd)\n\tif [ \"$isExc\" = \"\" ];then\n\t\techo \"exclude=httpd nginx php mysql mairadb python-psutil python2-psutil\" >> $yumPath\n\tfi\n\n\t#SYS_TYPE=$(uname -a|grep x86_64)\n\t#yumBaseUrl=$(cat /etc/yum.repos.d/CentOS-Base.repo|grep baseurl=http|cut -d '=' -f 2|cut -d '$' -f 1|head -n 1)\n\t#[ \"${yumBaseUrl}\" ] && checkYumRepo=$(curl --connect-timeout 5 --head -s -o /dev/null -w %{http_code} ${yumBaseUrl})\t\n\t#if [ \"${checkYumRepo}\" != \"200\" ] && [ \"${SYS_TYPE}\" ];then\n\t#\tcurl -Ss --connect-timeout 3 -m 60 https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/yumRepo_select.sh|bash\n\t#fi\n\t\n\t#尝试同步时间(从bt.cn)\n\techo 'Synchronizing system time...'\n\tgetBtTime=$(curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/index/get_time)\n\tif [ \"${getBtTime}\" ];then\t\n\t\tdate -s \"$(date -d @$getBtTime +\"%Y-%m-%d %H:%M:%S\")\"\n\tfi\n\n\tif [ -z \"${Centos8Check}\" ]; then\n\t\tyum install ntp -y\n\t\trm -rf /etc/localtime\n\t\tln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime\n\n\t\t#尝试同步国际时间(从ntp服务器)\n\t\tntpdate 0.asia.pool.ntp.org\n\t\tsetenforce 0\n\tfi\n\n\tstartTime=`date +%s`\n\n\tsed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config\n\t#yum remove -y python-requests python3-requests python-greenlet python3-greenlet\n\tyumPacks=\"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\"\n\tyum install -y ${yumPacks}\n\n\tfor yumPack in ${yumPacks}\n\tdo\n\t\trpmPack=$(rpm -q ${yumPack})\n\t\tpackCheck=$(echo ${rpmPack}|grep not)\n\t\tif [ \"${packCheck}\" ]; then\n\t\t\tyum install ${yumPack} -y\n\t\tfi\n\tdone\n\tif [ -f \"/usr/bin/dnf\" ]; then\n\t\tdnf install -y redhat-rpm-config\n\tfi\n\n\tALI_OS=$(cat /etc/redhat-release |grep \"Alibaba Cloud Linux release 3\")\n\tif [ -z \"${ALI_OS}\" ];then \n\t\tyum install epel-release -y\n\tfi\n}\nInstall_Deb_Pack(){\n\tln -sf bash /bin/sh\n\tapt-get update -y\n\tapt-get install ruby -y\n\tapt-get install lsb-release -y\n\t#apt-get install ntp ntpdate -y\n\t#/etc/init.d/ntp stop\n\t#update-rc.d ntp remove\n\t#cat >>~/.profile<<EOF\n\t#TZ='Asia/Shanghai'; export TZ\n\t#EOF\n\t#rm -rf /etc/localtime\n\t#cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime\n\t#echo 'Synchronizing system time...'\n\t#ntpdate 0.asia.pool.ntp.org\n\t#apt-get upgrade -y\n\tdebPacks=\"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\";\n\tapt-get install -y $debPacks --force-yes\n\n\tfor debPack in ${debPacks}\n\tdo\n\t\tpackCheck=$(dpkg -l ${debPack})\n\t\tif [ \"$?\" -ne \"0\" ] ;then\n\t\t\tapt-get install -y debPack\n\t\tfi\n\tdone\n\n\tif [ ! -d '/etc/letsencrypt' ];then\n\t\tmkdir -p /etc/letsencryp\n\t\tmkdir -p /var/spool/cron\n\t\tif [ ! -f '/var/spool/cron/crontabs/root' ];then\n\t\t\techo '' > /var/spool/cron/crontabs/root\n\t\t\tchmod 600 /var/spool/cron/crontabs/root\n\t\tfi\t\n\tfi\n}\nGet_Versions(){\n\tredhat_version_file=\"/etc/redhat-release\"\n\tdeb_version_file=\"/etc/issue\"\n\tif [ -f $redhat_version_file ];then\n\t\tos_type='el'\n\t\tis_aliyunos=$(cat $redhat_version_file|grep Aliyun)\n\t\tif [ \"$is_aliyunos\" != \"\" ];then\n\t\t\treturn\n\t\tfi\n\t\tos_version=$(cat $redhat_version_file|grep CentOS|grep -Eo '([0-9]+\\.)+[0-9]+'|grep -Eo '^[0-9]')\n\t\tif [ \"${os_version}\" = \"5\" ];then\n\t\t\tos_version=\"\"\n\t\tfi\n\t\tif [ -z \"${os_version}\" ];then\n\t\t\tos_version=$(cat /etc/redhat-release |grep Stream|grep -oE 8)\n\t\tfi\n\telse\n\t\tos_type='ubuntu'\n\t\tos_version=$(cat $deb_version_file|grep Ubuntu|grep -Eo '([0-9]+\\.)+[0-9]+'|grep -Eo '^[0-9]+')\n\t\tif [ \"${os_version}\" = \"\" ];then\n\t\t\tos_type='debian'\n\t\t\tos_version=$(cat $deb_version_file|grep Debian|grep -Eo '([0-9]+\\.)+[0-9]+'|grep -Eo '[0-9]+')\n\t\t\tif [ \"${os_version}\" = \"\" ];then\n\t\t\t\tos_version=$(cat $deb_version_file|grep Debian|grep -Eo '[0-9]+')\n\t\t\tfi\n\t\t\tif [ \"${os_version}\" = \"8\" ];then\n\t\t\t\tos_version=\"\"\n\t\t\tfi\n\t\t\tif [ \"${is64bit}\" = '32' ];then\n\t\t\t\tos_version=\"\"\n\t\t\tfi\n\t\telse\n\t\t\tif [ \"$os_version\" = \"14\" ];then\n\t\t\t\tos_version=\"\"\n\t\t\tfi\n\t\t\tif [ \"$os_version\" = \"12\" ];then\n\t\t\t\tos_version=\"\"\n\t\t\tfi\n\t\t\tif [ \"$os_version\" = \"19\" ];then\n\t\t\t\tos_version=\"\"\n\t\t\tfi\n\t\t\tif [ \"$os_version\" = \"21\" ];then\n\t\t\t\tos_version=\"\"\n\t\t\tfi\n\t\t\tif [ \"$os_version\" = \"20\" ];then\n\t\t\t\tos_version2004=$(cat /etc/issue|grep 20.04)\n\t\t\t\tif [ -z \"${os_version2004}\" ];then\n\t\t\t\t\tos_version=\"\"\n\t\t\t\tfi\n\t\t\tfi\n\t\tfi\n\tfi\n}\nInstall_Python_Lib(){\n\tcurl -Ss --connect-timeout 3 -m 60 https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/pip_select.sh|bash\n\tpyenv_path=\"/www/server/panel\"\n\tif [ -f $pyenv_path/pyenv/bin/python ];then\n\t \tis_ssl=$($python_bin -c \"import ssl\" 2>&1|grep cannot)\n\t\t$pyenv_path/pyenv/bin/python3.7 -V\n\t\tif [ $? -eq 0 ] && [ -z \"${is_ssl}\" ];then\n\t\t\tchmod -R 700 $pyenv_path/pyenv/bin\n\t\t\tis_package=$($python_bin -m psutil 2>&1|grep package)\n\t\t\tif [ \"$is_package\" = \"\" ];then\n\t\t\t\twget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip.txt -T 5\n\t\t\t\t$pyenv_path/pyenv/bin/pip install -U pip\n\t\t\t\t$pyenv_path/pyenv/bin/pip install -U setuptools\n\t\t\t\t$pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt\n\t\t\tfi\n\t\t\tsource $pyenv_path/pyenv/bin/activate\n\t\t\treturn\n\t\telse\n\t\t\trm -rf $pyenv_path/pyenv\n\t\tfi\n\tfi\n\n\tpy_version=\"3.7.8\"\n\tmkdir -p $pyenv_path\n\techo \"True\" > /www/disk.pl\n\tif [ ! -w /www/disk.pl ];then\n\t\tRed_Error \"ERROR: Install python env fielded.\" \"ERROR: /www目录无法写入，请检查目录/用户/磁盘权限！\"\n\tfi\n\tos_type='el'\n\tos_version='7'\n\tis_export_openssl=0\n\tGet_Versions\n\n\techo \"OS: $os_type - $os_version\"\n\tis_aarch64=$(uname -a|grep aarch64)\n\tif [ \"$is_aarch64\" != \"\" ];then\n\t\tis64bit=\"aarch64\"\n\tfi\n\t\n\tif [ -f \"/www/server/panel/pymake.pl\" ];then\n\t\tos_version=\"\"\n\t\trm -f /www/server/panel/pymake.pl\n\tfi\t\n\n\tif [ \"${os_version}\" != \"\" ];then\n\t\tpyenv_file=\"/www/pyenv.tar.gz\"\n\t\twget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 10\n\t\ttmp_size=$(du -b $pyenv_file|awk '{print $1}')\n\t\tif [ $tmp_size -lt 703460 ];then\n\t\t\trm -f $pyenv_file\n\t\t\techo \"ERROR: Download python env fielded.\"\n\t\telse\n\t\t\techo \"Install python env...\"\n\t\t\ttar zxvf $pyenv_file -C $pyenv_path/ > /dev/null\n\t\t\tchmod -R 700 $pyenv_path/pyenv/bin\n\t\t\tif [ ! -f $pyenv_path/pyenv/bin/python ];then\n\t\t\t\trm -f $pyenv_file\n\t\t\t\tRed_Error \"ERROR: Install python env fielded.\" \"ERROR: 下载宝塔运行环境失败，请尝试重新安装！\" \n\t\t\tfi\n\t\t\t$pyenv_path/pyenv/bin/python3.7 -V\n\t\t\tif [ $? -eq 0 ];then\n\t\t\t\trm -f $pyenv_file\n\t\t\t\tln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip\n\t\t\t\tln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython\n\t\t\t\tsource $pyenv_path/pyenv/bin/activate\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\trm -f $pyenv_file\n\t\t\t\trm -rf $pyenv_path/pyenv\n\t\t\tfi\n\t\tfi\n\tfi\n\n\tcd /www\n\tpython_src='/www/python_src.tar.xz'\n\tpython_src_path=\"/www/Python-${py_version}\"\n\twget -O $python_src $download_Url/src/Python-${py_version}.tar.xz -T 5\n\ttmp_size=$(du -b $python_src|awk '{print $1}')\n\tif [ $tmp_size -lt 10703460 ];then\n\t\trm -f $python_src\n\t\tRed_Error \"ERROR: Download python source code fielded.\" \"ERROR: 下载宝塔运行环境失败，请尝试重新安装！\"\n\tfi\n\ttar xvf $python_src\n\trm -f $python_src\n\tcd $python_src_path\n\t./configure --prefix=$pyenv_path/pyenv\n\tmake -j$cpu_cpunt\n\tmake install\n\tif [ ! -f $pyenv_path/pyenv/bin/python3.7 ];then\n\t\trm -rf $python_src_path\n\t\tRed_Error \"ERROR: Make python env fielded.\" \"ERROR: 编译宝塔运行环境失败！\"\n\tfi\n\tcd ~\n\trm -rf $python_src_path\n\twget -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -T 5\n\twget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip-3.7.8.txt -T 5\n\tln -sf $pyenv_path/pyenv/bin/pip3.7 $pyenv_path/pyenv/bin/pip\n\tln -sf $pyenv_path/pyenv/bin/python3.7 $pyenv_path/pyenv/bin/python\n\tln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip\n\tln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython\n\tchmod -R 700 $pyenv_path/pyenv/bin\n\t$pyenv_path/pyenv/bin/pip install -U pip\n\t$pyenv_path/pyenv/bin/pip install -U setuptools\n\t$pyenv_path/pyenv/bin/pip install -U wheel==0.34.2 \n\t$pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt\n\tsource $pyenv_path/pyenv/bin/activate\n\n\tis_gevent=$($python_bin -m gevent 2>&1|grep -oE package)\n\tis_psutil=$($python_bin -m psutil 2>&1|grep -oE package)\n\tif [ \"${is_gevent}\" != \"${is_psutil}\" ];then\n\t\tRed_Error \"ERROR: psutil/gevent install failed!\"\n\tfi\n}\nInstall_Bt(){\n\tpanelPort=\"8888\"\n\tif [ -f ${setup_path}/server/panel/data/port.pl ];then\n\t\tpanelPort=$(cat ${setup_path}/server/panel/data/port.pl)\n\tfi\n\tmkdir -p ${setup_path}/server/panel/logs\n\tmkdir -p ${setup_path}/server/panel/vhost/apache\n\tmkdir -p ${setup_path}/server/panel/vhost/nginx\n\tmkdir -p ${setup_path}/server/panel/vhost/rewrite\n\tmkdir -p ${setup_path}/server/panel/install\n\tmkdir -p /www/server\n\tmkdir -p /www/wwwroot\n\tmkdir -p /www/wwwlogs\n\tmkdir -p /www/backup/database\n\tmkdir -p /www/backup/site\n\n\tif [ -f \"/etc/init.d/bt\" ]; then\n\t\t/etc/init.d/bt stop\n\t\tsleep 1\n\tfi\n\n\twget -O /etc/init.d/bt https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/bt6.init -T 10\n\twget -O /www/server/panel/install/public.sh https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/public.sh -T 10\n\twget -O panel.zip https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/panel6.zip -T 10\n\n\tif [ -f \"${setup_path}/server/panel/data/default.db\" ];then\n\t\tif [ -d \"/${setup_path}/server/panel/old_data\" ];then\n\t\t\trm -rf ${setup_path}/server/panel/old_data\n\t\tfi\n\t\tmkdir -p ${setup_path}/server/panel/old_data\n\t\td_format=$(date +\"%Y%m%d_%H%M%S\")\n\t\t\\cp -arf ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/data/default_backup_${d_format}.db\n\t\tmv -f ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/old_data/default.db\n\t\tmv -f ${setup_path}/server/panel/data/system.db ${setup_path}/server/panel/old_data/system.db\n\t\tmv -f ${setup_path}/server/panel/data/port.pl ${setup_path}/server/panel/old_data/port.pl\n\t\tmv -f ${setup_path}/server/panel/data/admin_path.pl ${setup_path}/server/panel/old_data/admin_path.pl\n\tfi\n\n\tif [ ! -f \"/usr/bin/unzip\" ]; then\n\t\tif [ \"${PM}\" = \"yum\" ]; then\n\t\t\tyum install unzip -y\n\t\telif [ \"${PM}\" = \"apt-get\" ]; then\n\t\t\tapt-get update\n\t\t\tapt-get install unzip -y\n\t\tfi\n\tfi\n\n\tunzip -o panel.zip -d ${setup_path}/server/ > /dev/null\n\n\tif [ -d \"${setup_path}/server/panel/old_data\" ];then\n\t\tmv -f ${setup_path}/server/panel/old_data/default.db ${setup_path}/server/panel/data/default.db\n\t\tmv -f ${setup_path}/server/panel/old_data/system.db ${setup_path}/server/panel/data/system.db\n\t\tmv -f ${setup_path}/server/panel/old_data/port.pl ${setup_path}/server/panel/data/port.pl\n\t\tmv -f ${setup_path}/server/panel/old_data/admin_path.pl ${setup_path}/server/panel/data/admin_path.pl\n\t\tif [ -d \"/${setup_path}/server/panel/old_data\" ];then\n\t\t\trm -rf ${setup_path}/server/panel/old_data\n\t\tfi\n\tfi\n\n\tif [ ! -f ${setup_path}/server/panel/tools.py ] || [ ! -f ${setup_path}/server/panel/BT-Panel ];then\n\t\tls -lh panel.zip\n\t\tRed_Error \"ERROR: Failed to download, please try install again!\" \"ERROR: 下载宝塔失败，请尝试重新安装！\"\n\tfi\n\n\trm -f panel.zip\n\trm -f ${setup_path}/server/panel/class/*.pyc\n\trm -f ${setup_path}/server/panel/*.pyc\n\n\tchmod +x /etc/init.d/bt\n\tchmod -R 600 ${setup_path}/server/panel\n\tchmod -R +x ${setup_path}/server/panel/script\n\tln -sf /etc/init.d/bt /usr/bin/bt\n\techo \"${panelPort}\" > ${setup_path}/server/panel/data/port.pl\n\twget -O /etc/init.d/bt https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/bt7.init -T 10\n\twget -O /www/server/panel/init.sh https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/bt7.init -T 10\n\twget -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softList.conf\n}\nSet_Bt_Panel(){\n\tpassword=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)\n\tsleep 1\n\tadmin_auth=\"/www/server/panel/data/admin_path.pl\"\n\tif [ ! -f ${admin_auth} ];then\n\t\tauth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)\n\t\techo \"/${auth_path}\" > ${admin_auth}\n\tfi\n\tauth_path=$(cat ${admin_auth})\n\tcd ${setup_path}/server/panel/\n\t/etc/init.d/bt start\n\t$python_bin -m py_compile tools.py\n\t$python_bin tools.py username\n\tusername=$($python_bin tools.py panel ${password})\n\tcd ~\n\techo \"${password}\" > ${setup_path}/server/panel/default.pl\n\tchmod 600 ${setup_path}/server/panel/default.pl\n\tsleep 3\n\t/etc/init.d/bt restart \t\n\tsleep 3\n\tisStart=$(ps aux |grep 'BT-Panel'|grep -v grep|awk '{print $2}')\n\tLOCAL_CURL=$(curl 127.0.0.1:8888/login 2>&1 |grep -i html)\n\tif [ -z \"${isStart}\" ] && [ -z \"${LOCAL_CURL}\" ];then\n\t\t/etc/init.d/bt 22\n\t\tcd /www/server/panel/pyenv/bin\n\t\ttouch t.pl\n\t\tls -al python3.7 python\n\t\tlsattr python3.7 python\n\t\tRed_Error \"ERROR: The BT-Panel service startup failed.\" \"ERROR: 宝塔启动失败\"\n\tfi\n}\nSet_Firewall(){\n\tsshPort=$(cat /etc/ssh/sshd_config | grep 'Port '|awk '{print $2}')\n\tif [ \"${PM}\" = \"apt-get\" ]; then\n\t\tapt-get install -y ufw\n\t\tif [ -f \"/usr/sbin/ufw\" ];then\n\t\t\tufw allow 20/tcp\n\t\t\tufw allow 21/tcp\n\t\t\tufw allow 22/tcp\n\t\t\tufw allow 80/tcp\n\t\t\tufw allow 888/tcp\n\t\t\tufw allow ${panelPort}/tcp\n\t\t\tufw allow ${sshPort}/tcp\n\t\t\tufw allow 39000:40000/tcp\n\t\t\tufw_status=`ufw status`\n\t\t\techo y|ufw enable\n\t\t\tufw default deny\n\t\t\tufw reload\n\t\tfi\n\telse\n\t\tif [ -f \"/etc/init.d/iptables\" ];then\n\t\t\tiptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT\n\t\t\tiptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT\n\t\t\tiptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT\n\t\t\tiptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT\n\t\t\tiptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${panelPort} -j ACCEPT\n\t\t\tiptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${sshPort} -j ACCEPT\n\t\t\tiptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 39000:40000 -j ACCEPT\n\t\t\t#iptables -I INPUT -p tcp -m state --state NEW -m udp --dport 39000:40000 -j ACCEPT\n\t\t\tiptables -A INPUT -p icmp --icmp-type any -j ACCEPT\n\t\t\tiptables -A INPUT -s localhost -d localhost -j ACCEPT\n\t\t\tiptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n\t\t\tiptables -P INPUT DROP\n\t\t\tservice iptables save\n\t\t\tsed -i \"s#IPTABLES_MODULES=\\\"\\\"#IPTABLES_MODULES=\\\"ip_conntrack_netbios_ns ip_conntrack_ftp ip_nat_ftp\\\"#\" /etc/sysconfig/iptables-config\n\t\t\tiptables_status=$(service iptables status | grep 'not running')\n\t\t\tif [ \"${iptables_status}\" == '' ];then\n\t\t\t\tservice iptables restart\n\t\t\tfi\n\t\telse\n\t\t\tAliyunCheck=$(cat /etc/redhat-release|grep \"Aliyun Linux\")\n\t\t\t[ \"${AliyunCheck}\" ] && return\n\t\t\tyum install firewalld -y\n\t\t\t[ \"${Centos8Check}\" ] && yum reinstall python3-six -y\n\t\t\tsystemctl enable firewalld\n\t\t\tsystemctl start firewalld\n\t\t\tfirewall-cmd --set-default-zone=public > /dev/null 2>&1\n\t\t\tfirewall-cmd --permanent --zone=public --add-port=20/tcp > /dev/null 2>&1\n\t\t\tfirewall-cmd --permanent --zone=public --add-port=21/tcp > /dev/null 2>&1\n\t\t\tfirewall-cmd --permanent --zone=public --add-port=22/tcp > /dev/null 2>&1\n\t\t\tfirewall-cmd --permanent --zone=public --add-port=80/tcp > /dev/null 2>&1\n\t\t\tfirewall-cmd --permanent --zone=public --add-port=${panelPort}/tcp > /dev/null 2>&1\n\t\t\tfirewall-cmd --permanent --zone=public --add-port=${sshPort}/tcp > /dev/null 2>&1\n\t\t\tfirewall-cmd --permanent --zone=public --add-port=39000-40000/tcp > /dev/null 2>&1\n\t\t\t#firewall-cmd --permanent --zone=public --add-port=39000-40000/udp > /dev/null 2>&1\n\t\t\tfirewall-cmd --reload\n\t\tfi\n\tfi\n}\nGet_Ip_Address(){\n\tgetIpAddress=\"\"\n\tgetIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)\n\tif [ -z \"${getIpAddress}\" ] || [ \"${getIpAddress}\" = \"0.0.0.0\" ]; then\n\t\tisHosts=$(cat /etc/hosts|grep 'www.bt.cn')\n\t\tif [ -z \"${isHosts}\" ];then\n\t\t\techo \"\" >> /etc/hosts\n\t\t\techo \"116.213.43.206 www.bt.cn\" >> /etc/hosts\n\t\t\tgetIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)\n\t\t\tif [ -z \"${getIpAddress}\" ];then\n\t\t\t\tsed -i \"/bt.cn/d\" /etc/hosts\n\t\t\tfi\n\t\tfi\n\tfi\n\n\tipv4Check=$($python_bin -c \"import re; print(re.match('^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$','${getIpAddress}'))\")\n\tif [ \"${ipv4Check}\" == \"None\" ];then\n\t\tipv6Address=$(echo ${getIpAddress}|tr -d \"[]\")\n\t\tipv6Check=$($python_bin -c \"import re; print(re.match('^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$','${ipv6Address}'))\")\n\t\tif [ \"${ipv6Check}\" == \"None\" ]; then\n\t\t\tgetIpAddress=\"SERVER_IP\"\n\t\telse\n\t\t\techo \"True\" > ${setup_path}/server/panel/data/ipv6.pl\n\t\t\tsleep 1\n\t\t\t/etc/init.d/bt restart\n\t\tfi\n\tfi\n\n\tif [ \"${getIpAddress}\" != \"SERVER_IP\" ];then\n\t\techo \"${getIpAddress}\" > ${setup_path}/server/panel/data/iplist.txt\n\tfi\n\tLOCAL_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)\n}\nSetup_Count(){\n\tcurl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/SetupCount?type=Linux\\&o=$1 > /dev/null 2>&1\n\tif [ \"$1\" != \"\" ];then\n\t\techo $1 > /www/server/panel/data/o.pl\n\t\tcd /www/server/panel\n\t\t$python_bin tools.py o\n\tfi\n\techo /www > /var/bt_setupPath.conf\n}\nInstall_Main(){\n\tstartTime=`date +%s`\n\tLock_Clear\n\tSystem_Check\n\tGet_Pack_Manager\n\tget_node_url\n\n\tMEM_TOTAL=$(free -g|grep Mem|awk '{print $2}')\n\tif [ \"${MEM_TOTAL}\" -le \"1\" ];then\n\t\tAuto_Swap\n\tfi\n\t\n\tif [ \"${PM}\" = \"yum\" ]; then\n\t\tInstall_RPM_Pack\n\telif [ \"${PM}\" = \"apt-get\" ]; then\n\t\tInstall_Deb_Pack\n\tfi\n\n\tInstall_Python_Lib\n\tInstall_Bt\n\t\n\n\tSet_Bt_Panel\n\tService_Add\n\tSet_Firewall\n\n\tGet_Ip_Address\n\tSetup_Count ${IDC_CODE}\n}\n\necho \"\n+----------------------------------------------------------------------\n| Bt-WebPanel FOR CentOS/Ubuntu/Debian\n+----------------------------------------------------------------------\n| Copyright © 2015-2099 BT-SOFT(http://www.bt.cn) All rights reserved.\n+----------------------------------------------------------------------\n| The WebPanel URL will be http://SERVER_IP:8888 when installed.\n+----------------------------------------------------------------------\n\"\nwhile [ \"$go\" != 'y' ] && [ \"$go\" != 'n' ]\ndo\n\tread -p \"Do you want to install Bt-Panel to the $setup_path directory now?(y/n): \" go;\ndone\n\nif [ \"$go\" == 'n' ];then\n\texit;\nfi\n\nInstall_Main\necho > /www/server/panel/data/bind.pl\necho -e \"==================================================================\"\necho -e \"\\033[32mCongratulations! Installed successfully!\\033[0m\"\necho -e \"==================================================================\"\necho  \"外网面板地址: http://${getIpAddress}:${panelPort}${auth_path}\"\necho  \"内网面板地址: http://${LOCAL_IP}:${panelPort}${auth_path}\"\necho -e \"username: $username\"\necho -e \"password: $password\"\necho -e \"\\033[33mIf you cannot access the panel,\\033[0m\"\necho -e \"\\033[33mrelease the following panel port [${panelPort}] in the security group\\033[0m\"\necho -e \"\\033[33m若无法访问面板，请检查防火墙/安全组是否有放行面板[${panelPort}]端口\\033[0m\"\necho -e \"==================================================================\"\n\nendTime=`date +%s`\n((outTime=($endTime-$startTime)/60))\necho -e \"Time consumed:\\033[32m $outTime \\033[0mMinute!\"\n\n\n"
  },
  {
    "path": "install/pip_select.sh",
    "content": "#!/bin/bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\npyenv_bin=/www/server/panel/pyenv/bin\nrep_path=${pyenv_bin}:$PATH\nif [ -d \"$pyenv_bin\" ];then\n\tPATH=$rep_path\nfi\nexport PATH\nLANG=en_US.UTF-8\nget_PIP_URL(){\n\tnodes=(https://mirrors.tencent.com/pypi/simple https://pypi.doubanio.com/simple https://mirrors.aliyun.com/pypi/simple https://pypi.tuna.tsinghua.edu.cn/simple https://pypi.org/simple);\n\ti=1;\n\tfor node in ${nodes[@]};\n\tdo\n\t\tstart=`date +%s.%N`\n\t\tresult=`curl -sS --connect-timeout 3 -m 60 $node/0/|grep Links`\n\t\tif [ \"$result\" != '' ];then\n\t\t\tend=`date +%s.%N`\n\t\t\tstart_s=`echo $start | cut -d '.' -f 1`\n\t\t\tstart_ns=`echo $start | cut -d '.' -f 2`\n\t\t\tend_s=`echo $end | cut -d '.' -f 1`\n\t\t\tend_ns=`echo $end | cut -d '.' -f 2`\n\t\t\ttime_micro=$(( (10#$end_s-10#$start_s)*1000000 + (10#$end_ns/1000 - 10#$start_ns/1000) ))\n\t\t\ttime_ms=$(($time_micro/1000))\n\t\t\tvalues[$i]=$time_ms;\n\t\t\turls[$time_ms]=$node\n\t\t\ti=$(($i+1))\n\t\t\tif [ $time_ms -lt 50 ];then\n\t\t\t\tbreak;\n\t\t\tfi\n\t\tfi\n\tdone\n\tj=5000\n\tfor n in ${values[@]};\n\tdo\n\t\tif [ $j -gt $n ];then\n\t\t\tj=$n\n\t\tfi\n\t\tif [ $j -lt 50 ];then\n\t\t\tbreak;\n\t\tfi\n\tdone\n\tif [ $j = 5000 ];then\n\t\tPIP_URL='False';\n\t\tT_HOST='False'\n\telse\n\t\tPIP_URL=${urls[$j]}\n\t\tmy_tmp=$(echo $PIP_URL|grep 'aliyun')\n\t\tif [ \"$my_tmp\" != \"\" ];then\n\t\t\tT_HOST=mirrors.aliyun.com\n\t\telif [ $(echo $PIP_URL|grep 'tencent') != \"\" ];then\n\t\t\tT_HOST=mirrors.tencent.com\n\t\telif [ $(echo $PIP_URL|grep 'doubanio') != \"\" ];then\n\t\t\tT_HOST=pypi.doubanio.com\n\t\telif [ $(echo $PIP_URL|grep 'tsinghua') != \"\" ];then\n\t\t\tT_HOST=pypi.tuna.tsinghua.edu.cn\n\t\telif [ $(echo $PIP_URL|grep 'pypi.org') != \"\" ];then\n\t\t\tT_HOST=pypi.org\n\t\tfi\n\tfi\n}\n\nget_PIP_URL\nif [ \"$PIP_URL\" != \"False\" ];then\n\techo \"$PIP_URL\"\n\tif [ ! -d ~/.pip ];then\n\t\tmkdir -p ~/.pip\n\tfi\n\tcat > ~/.pip/pip.conf <<EOF\n[global]\nindex-url = $PIP_URL\n\n[install]\ntrusted-host = $T_HOST\nEOF\nelse\n\trm -f ~/.pip/pip.conf\nfi\n"
  },
  {
    "path": "install/public.sh",
    "content": "#!/bin/bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\npyenv_bin=/www/server/panel/pyenv/bin\nrep_path=${pyenv_bin}:$PATH\nif [ -d \"$pyenv_bin\" ];then\n\tPATH=$rep_path\nfi\nexport PATH\nexport LANG=en_US.UTF-8\nexport LANGUAGE=en_US:en\n\nget_node_url(){\n\tnodes=(http://dg2.bt.cn http://dg1.bt.cn http://36.133.1.8:5880 http://123.129.198.197 http://38.34.185.130 http://116.213.43.206:5880 http://128.1.164.196);\n\ttmp_file1=/dev/shm/net_test1.pl\n\ttmp_file2=/dev/shm/net_test2.pl\n\t[ -f \"${tmp_file1}\" ] && rm -f ${tmp_file1}\n\t[ -f \"${tmp_file2}\" ] && rm -f ${tmp_file2}\n\ttouch $tmp_file1\n\ttouch $tmp_file2\n\tfor node in ${nodes[@]};\n\tdo\n\t\tNODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w \"%{http_code} %{time_total}\" ${node}/net_test|xargs)\n\t\tRES=$(echo ${NODE_CHECK}|awk '{print $1}')\n\t\tNODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $2}')\n\t\tTIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $3 * 1000 - 500 }'|cut -d '.' -f 1)\n\t\tif [ \"${NODE_STATUS}\" == \"200\" ];then\n\t\t\tif [ $TIME_TOTAL -lt 100 ];then\n\t\t\t\tif [ $RES -ge 1500 ];then\n\t\t\t\t\techo \"$RES $node\" >> $tmp_file1\n\t\t\t\tfi\n\t\t\telse\n\t\t\t\tif [ $RES -ge 1500 ];then\n\t\t\t\t\techo \"$TIME_TOTAL $node\" >> $tmp_file2\n\t\t\t\tfi\n\t\t\tfi\n\n\t\t\ti=$(($i+1))\n\t\t\tif [ $TIME_TOTAL -lt 100 ];then\n\t\t\t\tif [ $RES -ge 3000 ];then\n\t\t\t\t\tbreak;\n\t\t\t\tfi\n\t\t\tfi\t\n\t\tfi\n\tdone\n\n\tNODE_URL=$(cat $tmp_file1|sort -r -g -t \" \" -k 1|head -n 1|awk '{print $2}')\n\tif [ -z \"$NODE_URL\" ];then\n\t\tNODE_URL=$(cat $tmp_file2|sort -g -t \" \" -k 1|head -n 1|awk '{print $2}')\n\t\tif [ -z \"$NODE_URL\" ];then\n\t\t\tNODE_URL='http://download.bt.cn';\n\t\tfi\n\tfi\n\trm -f $tmp_file1\n\trm -f $tmp_file2\n}\n\nGetCpuStat(){\n\ttime1=$(cat /proc/stat |grep 'cpu ')\n\tsleep 1\n\ttime2=$(cat /proc/stat |grep 'cpu ')\n\tcpuTime1=$(echo ${time1}|awk '{print $2+$3+$4+$5+$6+$7+$8}')\n\tcpuTime2=$(echo ${time2}|awk '{print $2+$3+$4+$5+$6+$7+$8}')\n\trunTime=$((${cpuTime2}-${cpuTime1}))\n\tidelTime1=$(echo ${time1}|awk '{print $5}')\n\tidelTime2=$(echo ${time2}|awk '{print $5}')\n\tidelTime=$((${idelTime2}-${idelTime1}))\n\tuseTime=$(((${runTime}-${idelTime})*3))\n\t[ ${useTime} -gt ${runTime} ] && cpuBusy=\"true\"\n\tif [ \"${cpuBusy}\" == \"true\" ]; then\n\t\tcpuCore=$((${cpuInfo}/2))\n\telse\n\t\tcpuCore=$((${cpuInfo}-1))\n\tfi\n}\nGetPackManager(){\n\tif [ -f \"/usr/bin/yum\" ] && [ -f \"/etc/yum.conf\" ]; then\n\t\tPM=\"yum\"\n\telif [ -f \"/usr/bin/apt-get\" ] && [ -f \"/usr/bin/dpkg\" ]; then\n\t\tPM=\"apt-get\"\t\t\n\tfi\n}\n\nbt_check(){\n\tp_path=/www/server/panel/class/panelPlugin.py\n\tif [ -f $p_path ];then\n\t\tis_ext=$(cat $p_path|grep btwaf)\n\t\tif [ \"$is_ext\" != \"\" ];then\n\t\t\tsend_check\n\t\tfi\n\tfi\n\t\n\tp_path=/www/server/panel/BTPanel/templates/default/index.html\n\tif [ -f $p_path ];then\n\t\tis_ext=$(cat $p_path|grep fbi)\n\t\tif [ \"$is_ext\" != \"\" ];then\n\t\t\tsend_check\n\t\tfi\n\tfi\n}\n\nsend_check(){\n\tchattr -i /etc/init.d/bt\n\tchmod +x /etc/init.d/bt\n\tp_path2=/www/server/panel/class/common.py\n\tp_version=$(cat $p_path2|grep \"version = \"|awk '{print $3}'|tr -cd [0-9.])\n\tcurl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/panel/notpro?version=$p_version\n\tNODE_URL=\"\"\n\texit 0;\n}\ninit_check(){\n\tCRACK_URL=(oss.yuewux.com);\n\tfor url in ${CRACK_URL[@]};\n\tdo\n\t\tCRACK_INIT=$(cat /etc/init.d/bt |grep ${url})\n\t\tif [ \"${CRACK_INIT}\" ];then\n\t\t\trm -rf /www/server/panel/class/*\n\t\t\tchattr +i /www/server/panel/class\n\t\t\tchattr -R +i /www/server/panel\n\t\t\tchattr +i /www \n\t\tfi\n\tdone\n}\nGetSysInfo(){\n\tif [ \"${PM}\" = \"yum\" ]; then\n\t\tSYS_VERSION=$(cat /etc/redhat-release)\n\telif [ \"${PM}\" = \"apt-get\" ]; then\n\t\tSYS_VERSION=$(cat /etc/issue)\n\tfi\n\tSYS_INFO=$(uname -msr)\n\tSYS_BIT=$(getconf LONG_BIT)\n\tMEM_TOTAL=$(free -m|grep Mem|awk '{print $2}')\n\tCPU_INFO=$(getconf _NPROCESSORS_ONLN)\n\tGCC_VER=$(gcc -v 2>&1|grep \"gcc version\"|awk '{print $3}')\n\tCMAKE_VER=$(cmake --version|grep version|awk '{print $3}')\n\n\techo -e ${SYS_VERSION}\n\techo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO} gcc:${GCC_VER} cmake:${CMAKE_VER}\n\techo -e ${SYS_INFO}\n}\ncpuInfo=$(getconf _NPROCESSORS_ONLN)\nif [ \"${cpuInfo}\" -ge \"4\" ];then\n\tGetCpuStat\nelse\n\tcpuCore=\"1\"\nfi\nGetPackManager\n\nif [ -d \"/www/server/phpmyadmin/pma\" ];then\n\trm -rf /www/server/phpmyadmin/pma\n\tEN_CHECK=$(cat /www/server/panel/config/config.json |grep English)\n\tif [ \"${EN_CHECK}\" ];then\n\t\tcurl https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/update6_en.sh|bash\n\telse\n\t\tcurl https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/update6.sh|bash\n\tfi\n\techo > /www/server/panel/data/restart.pl\nfi\n\nif [ ! $NODE_URL ];then\n\tEN_CHECK=$(cat /www/server/panel/config/config.json |grep English)\n\tif [ -z \"${EN_CHECK}\" ];then\n\t\techo '正在选择下载节点...';\n\telse\n\t\techo \"selecting download node...\";\n\tfi\n\tget_node_url\n\tbt_check\nfi\n\n"
  },
  {
    "path": "install/src/bt6.init",
    "content": "#!/bin/bash\n# chkconfig: 2345 55 25\n# description: bt Cloud Service\n\n### BEGIN INIT INFO\n# Provides:          bt\n# Required-Start:    $all\n# Required-Stop:     $all\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: starts bt\n# Description:       starts the bt\n### END INIT INFO\npanel_init(){\n        panel_path=/www/server/panel\n        pidfile=$panel_path/logs/panel.pid\n        cd $panel_path\n        env_path=$panel_path/pyenv/bin/activate\n        if [ -f $env_path ];then\n                source $env_path\n                pythonV=$panel_path/pyenv/bin/python\n                chmod -R 700 $panel_path/pyenv/bin\n        else\n                pythonV=/usr/bin/python\n        fi\n        reg=\"^#\\!$pythonV\\$\"\n        is_sed=$(cat $panel_path/BT-Panel|head -n 1|grep -E $reg)\n        if [ \"${is_sed}\" = \"\" ];then\n                sed -i \"s@^#!.*@#!$pythonV@\" $panel_path/BT-Panel\n        fi\n        is_sed=$(cat $panel_path/BT-Task|head -n 1|grep -E $reg)\n        if [ \"${is_sed}\" = \"\" ];then\n                sed -i \"s@^#!.*@#!$pythonV@\" $panel_path/BT-Task\n        fi\n        chmod 700 $panel_path/BT-Panel\n        chmod 700 $panel_path/BT-Task\n        log_file=$panel_path/logs/error.log\n        task_log_file=$panel_path/logs/task.log\n        if [ -f $panel_path/data/ssl.pl ];then\n                log_file=/dev/null\n        fi\n\n        port=$(cat $panel_path/data/port.pl)\n}\npanel_init\n\nget_panel_pids(){\n        isStart=$(ps aux|grep -E '(runserver|BT-Panel)'|grep -v grep|awk '{print $2}'|xargs)\n        pids=$isStart\n        arr=$isStart\n}\n\nget_task_pids(){\n        isStart=$(ps aux|grep -E '(task.py|BT-Task)'|grep -v grep|awk '{print $2}'|xargs)\n        pids=$isStart\n        arr=$isStart    \n}\n\npanel_start()\n{\n        isStart=`ps aux|grep 'runserver:app'|grep -v grep|awk '{print $2}'`\n        if [ \"$isStart\" != '' ];then\n                kill -9 $isStart\n        fi\n        get_panel_pids\n        if [ \"$isStart\" == '' ];then\n                rm -f $pidfile\n                panel_port_check\n                echo -e \"Starting Bt-Panel...\\c\"\n                nohup $panel_path/BT-Panel >> $log_file 2>&1 &\n                isStart=\"\"\n                n=0\n                while [[ \"$isStart\" == \"\" ]];\n                do\n                        echo -e \".\\c\"\n                        sleep 0.5\n                        get_panel_pids\n                        let n+=1\n                        if [ $n -gt 8 ];then\n                                break;\n                        fi\n                done\n                if [ \"$isStart\" == '' ];then\n                        echo -e \"\\033[31mfailed\\033[0m\"\n                        echo '------------------------------------------------------'\n                        tail -n 20 $log_file\n                        echo '------------------------------------------------------'\n                        echo -e \"\\033[31mError: BT-Panel service startup failed.\\033[0m\"\n                fi\n                echo -e \"\t\\033[32mdone\\033[0m\"\n        else\n                echo \"Starting Bt-Panel... Bt-Panel (pid $(echo $isStart)) already running\"\n        fi\n        \n        get_task_pids\n        if [ \"$isStart\" == '' ];then\n                echo -e \"Starting Bt-Tasks... \\c\"\n                nohup $panel_path/BT-Task >> $task_log_file 2>&1 &\n                sleep 0.2\n                get_task_pids\n                if [ \"$isStart\" == '' ];then\n                        echo -e \"\\033[31mfailed\\033[0m\"\n                        echo '------------------------------------------------------'\n                        tail -n 20 $task_log_file\n                        echo '------------------------------------------------------'\n                        echo -e \"\\033[31mError: BT-Task service startup failed.\\033[0m\"\n                        return;\n                fi\n                echo -e \"\t\\033[32mdone\\033[0m\"\n        else\n                echo \"Starting Bt-Tasks... Bt-Tasks (pid $isStart) already running\"\n        fi\n}\n\npanel_port_check()\n{\n\tis_process=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $1}'|sort|uniq|xargs)\n\tfor pn in ${is_process[@]}\n        do\n          if [ \"$pn\" = \"nginx\" ];then\n\t\t\t\t/etc/init.d/nginx restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"httpd\" ];then\n\t\t\t\t/etc/init.d/httpd restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"mysqld\" ];then\n\t\t\t\t/etc/init.d/mysqld restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"superviso\" ];then\n\t\t\t\tpkill -9 superviso\n\t\t\t\tsleep 0.2\n\t\t\t\tsupervisord -c /etc/supervisor/supervisord.conf\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"pure-ftpd\" ];then\n\t\t\t\t/etc/init.d/pure-ftpd restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"memcached\" ];then\n\t\t\t\t/etc/init.d/memcached restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"sudo\" ];then\n\t\t\t\tif [ -f /etc/init.d/redis ];then\n\t\t\t\t\t/etc/init.d/redis restart\n\t\t\t\tfi\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"php-fpm\" ];then\n\t\t\t\tphp_v=(52 53 54 55 56 70 71 72 73 74);\n\t\t\t\tfor pv in ${php_v[@]};\n\t\t\t\tdo\n\t\t\t\t\tif [ -f /etc/init.d/php-fpm-${pv} ];then\n\t\t\t\t\t\tif [ -f /www/server/php/%{pv}/sbin/php-fpm ];then\n\t\t\t\t\t\t\tif [ -f /tmp/php-cgi-${pv}.sock ];then\n\t\t\t\t\t\t\t\t/etc/init.d/php-fpm-${pv} start\n\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\t/etc/init.d/php-fpm-${pv} restart\n\t\t\t\t\t\tfi\n\t\t\t\t\tfi\n\t\t\t\tdone\n\t\t  fi\n        done\n\t\n\tis_ports=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $2}'|xargs)\n\tif [ \"$is_ports\" != '' ];then\n\t\tkill -9 $is_ports\n\t\tsleep 1\n\tfi\n}\n\npanel_stop()\n{\n        echo -e \"Stopping Bt-Tasks...\\c\";\n        get_task_pids\n        arr=($pids)\n        for p in ${arr[@]}\n        do\n                kill -9 $p\n        done\n        echo -e \"\t\\033[32mdone\\033[0m\"\n\n        echo -e \"Stopping Bt-Panel...\\c\";\n\n        get_panel_pids\n        for p in ${arr[@]}\n        do\n                kill -9 $p &>/dev/null\n        done\n        \n        if [ -f $pidfile ];then\n                rm -f $pidfile\n        fi\n        echo -e \"\t\\033[32mdone\\033[0m\"\n}\n\npanel_status()\n{\n        port=$(cat $panel_path/data/port.pl)\n        get_panel_pids\n        if [ \"$isStart\" != '' ];then\n                echo -e \"\\033[32mBt-Panel (pid $(echo $isStart)) already running\\033[0m\"\n        else\n                echo -e \"\\033[31mBt-Panel not running\\033[0m\"\n        fi\n        \n        get_task_pids\n        if [ \"$isStart\" != '' ];then\n                echo -e \"\\033[32mBt-Task (pid $isStart) already running\\033[0m\"\n        else\n                echo -e \"\\033[31mBt-Task not running\\033[0m\"\n        fi\n}\n\npanel_reload()\n{\n\tisStart=$(ps aux|grep 'runserver:app'|grep -v grep|awk '{print $2}')\n        if [ \"$isStart\" != '' ];then\n\t\tkill -9 $isStart\n\t\tsleep 0.5\n\tfi\n\tget_panel_pids\n        if [ \"$isStart\" != '' ];then\n    \t\n\t    get_panel_pids\n\tfor p in ${arr[@]}\n        do\n                kill -9 $p\n        done\n\t\trm -f $pidfile\n\t\tpanel_port_check\n\t\techo -e \"Reload Bt-Panel.\\c\";\n                nohup $panel_path/BT-Panel >> $log_file 2>&1 &\n\t\tisStart=\"\"\n\t\tn=0\n\t\twhile [[ \"$isStart\" == \"\" ]];\n\t\tdo\n\t\t\techo -e \".\\c\"\n\t\t\tsleep 0.5\n\t\t\tget_panel_pids\n\t\t\tlet n+=1\n\t\t\tif [ $n -gt 8 ];then\n\t\t\t\tbreak;\n\t\t\tfi\n\t\tdone\n        if [ \"$isStart\" == '' ];then\n                echo -e \"\\033[31mfailed\\033[0m\"\n                echo '------------------------------------------------------'\n                tail -n 20 $log_file\n                echo '------------------------------------------------------'\n                echo -e \"\\033[31mError: BT-Panel service startup failed.\\033[0m\"\n                return;\n        fi\n        echo -e \"\t\\033[32mdone\\033[0m\"\n    else\n        echo -e \"\\033[31mBt-Panel not running\\033[0m\"\n        panel_start\n    fi\n}\n\ninstall_used()\n{\n        if [ ! -f $panel_path/aliyun.pl ];then\n                return;\n        fi\n        password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 12)\n        username=$($pythonV $panel_path/tools.py panel $password)\n        echo \"$password\" > $panel_path/default.pl\n        rm -f $panel_path/aliyun.pl\n}\n\nerror_logs()\n{\n\ttail -n 100 $log_file\n}\n\n\ncase \"$1\" in\n        'start')\n                install_used\n                panel_start\n                ;;\n        'stop')\n                panel_stop\n                ;;\n        'restart')\n                panel_stop\n\t\t\t\tsleep 1\n                panel_start\n                ;;\n        'reload')\n                panel_reload\n                ;;\n        'status')\n                panel_status\n                ;;\n        'logs')\n        \t\terror_logs\n        \t\t;;\n        'panel')\n        \t\t$pythonV $panel_path/tools.py cli $2\n        \t\t;;\n        'default')\n                port=$(cat $panel_path/data/port.pl)\n                password=$(cat $panel_path/default.pl)\n                if [ -f $panel_path/data/domain.conf ];then\n                \taddress=$(cat $panel_path/data/domain.conf)\n                fi\n                if [ -f $panel_path/data/admin_path.pl ];then\n                \tauth_path=$(cat $panel_path/data/admin_path.pl)\n                fi\n                if [ \"$address\" = \"\" ];then\n                \taddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)\n                fi\n\t\t\t\tpool=http\n\t\t\t\tif [ -f $panel_path/data/ssl.pl ];then\n\t\t\t\t\tpool=https\n\t\t\t\tfi\n                echo -e \"==================================================================\"\n                echo -e \"\\033[32mBT-Panel default info!\\033[0m\"\n                echo -e \"==================================================================\"\n                echo  \"Bt-Panel-URL: $pool://$address:$port$auth_path\"\n                echo -e `$pythonV $panel_path/tools.py username`\n                echo -e \"password: $password\"\n                echo -e \"\\033[33mWarning:\\033[0m\"\n                echo -e \"\\033[33mIf you cannot access the panel, \\033[0m\"\n                echo -e \"\\033[33mrelease the following port (8888|888|80|443|20|21) in the security group\\033[0m\"\n                echo -e \"==================================================================\"\n                ;;\n        *)\n                $pythonV $panel_path/tools.py cli $1\n        ;;\nesac\n"
  },
  {
    "path": "install/src/bt7.init",
    "content": "#!/bin/bash\n# chkconfig: 2345 55 25\n# description: bt Cloud Service\n\n### BEGIN INIT INFO\n# Provides:          bt\n# Required-Start:    $all\n# Required-Stop:     $all\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: starts bt\n# Description:       starts the bt\n### END INIT INFO\npanel_init(){\n        panel_path=/www/server/panel\n        pidfile=$panel_path/logs/panel.pid\n        cd $panel_path\n        env_path=$panel_path/pyenv/bin/activate\n        if [ -f $env_path ];then\n                source $env_path\n                pythonV=$panel_path/pyenv/bin/python\n                chmod -R 700 $panel_path/pyenv/bin\n        else\n                pythonV=/usr/bin/python\n        fi\n        reg=\"^#\\!$pythonV\\$\"\n        is_sed=$(cat $panel_path/BT-Panel|head -n 1|grep -E $reg)\n        if [ \"${is_sed}\" = \"\" ];then\n                sed -i \"s@^#!.*@#!$pythonV@\" $panel_path/BT-Panel\n        fi\n        is_sed=$(cat $panel_path/BT-Task|head -n 1|grep -E $reg)\n        if [ \"${is_sed}\" = \"\" ];then\n                sed -i \"s@^#!.*@#!$pythonV@\" $panel_path/BT-Task\n        fi\n        chmod 700 $panel_path/BT-Panel\n        chmod 700 $panel_path/BT-Task\n        log_file=$panel_path/logs/error.log\n        task_log_file=$panel_path/logs/task.log\n        if [ -f $panel_path/data/ssl.pl ];then\n                log_file=/dev/null\n        fi\n\n        port=$(cat $panel_path/data/port.pl)\n}\npanel_init\n\nget_panel_pids(){\n        isStart=$(ps aux|grep -E '(runserver|BT-Panel)'|grep -v grep|awk '{print $2}'|xargs)\n        pids=$isStart\n        arr=$isStart\n}\n\nget_task_pids(){\n        isStart=$(ps aux|grep -E '(task.py|BT-Task)'|grep -v grep|awk '{print $2}'|xargs)\n        pids=$isStart\n        arr=$isStart    \n}\n\npanel_start()\n{\n        isStart=`ps aux|grep 'runserver:app'|grep -v grep|awk '{print $2}'`\n        if [ \"$isStart\" != '' ];then\n                kill -9 $isStart\n        fi\n        get_panel_pids\n        if [ \"$isStart\" == '' ];then\n                rm -f $pidfile\n                panel_port_check\n                echo -e \"Starting Bt-Panel...\\c\"\n                nohup $panel_path/BT-Panel >> $log_file 2>&1 &\n                isStart=\"\"\n                n=0\n                while [[ \"$isStart\" == \"\" ]];\n                do\n                        echo -e \".\\c\"\n                        sleep 0.5\n                        get_panel_pids\n                        let n+=1\n                        if [ $n -gt 8 ];then\n                                break;\n                        fi\n                done\n                if [ \"$isStart\" == '' ];then\n                        echo -e \"\\033[31mfailed\\033[0m\"\n                        echo '------------------------------------------------------'\n                        tail -n 20 $log_file\n                        echo '------------------------------------------------------'\n                        echo -e \"\\033[31mError: BT-Panel service startup failed.\\033[0m\"\n                fi\n                echo -e \"\t\\033[32mdone\\033[0m\"\n        else\n                echo \"Starting Bt-Panel... Bt-Panel (pid $(echo $isStart)) already running\"\n        fi\n        \n        get_task_pids\n        if [ \"$isStart\" == '' ];then\n                echo -e \"Starting Bt-Tasks... \\c\"\n                nohup $panel_path/BT-Task >> $task_log_file 2>&1 &\n                sleep 0.2\n                get_task_pids\n                if [ \"$isStart\" == '' ];then\n                        echo -e \"\\033[31mfailed\\033[0m\"\n                        echo '------------------------------------------------------'\n                        tail -n 20 $task_log_file\n                        echo '------------------------------------------------------'\n                        echo -e \"\\033[31mError: BT-Task service startup failed.\\033[0m\"\n                        return;\n                fi\n                echo -e \"\t\\033[32mdone\\033[0m\"\n        else\n                echo \"Starting Bt-Tasks... Bt-Tasks (pid $isStart) already running\"\n        fi\n}\n\npanel_port_check()\n{\n\tis_process=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $1}'|sort|uniq|xargs)\n\tfor pn in ${is_process[@]}\n        do\n          if [ \"$pn\" = \"nginx\" ];then\n\t\t\t\t/etc/init.d/nginx restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"httpd\" ];then\n\t\t\t\t/etc/init.d/httpd restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"mysqld\" ];then\n\t\t\t\t/etc/init.d/mysqld restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"superviso\" ];then\n\t\t\t\tpkill -9 superviso\n\t\t\t\tsleep 0.2\n\t\t\t\tsupervisord -c /etc/supervisor/supervisord.conf\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"pure-ftpd\" ];then\n\t\t\t\t/etc/init.d/pure-ftpd restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"memcached\" ];then\n\t\t\t\t/etc/init.d/memcached restart\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"sudo\" ];then\n\t\t\t\tif [ -f /etc/init.d/redis ];then\n\t\t\t\t\t/etc/init.d/redis restart\n\t\t\t\tfi\n\t\t  fi\n\n\t\t  if [ \"$pn\" = \"php-fpm\" ];then\n\t\t\t\tphp_v=(52 53 54 55 56 70 71 72 73 74);\n\t\t\t\tfor pv in ${php_v[@]};\n\t\t\t\tdo\n\t\t\t\t\tif [ -f /etc/init.d/php-fpm-${pv} ];then\n\t\t\t\t\t\tif [ -f /www/server/php/%{pv}/sbin/php-fpm ];then\n\t\t\t\t\t\t\tif [ -f /tmp/php-cgi-${pv}.sock ];then\n\t\t\t\t\t\t\t\t/etc/init.d/php-fpm-${pv} start\n\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\t/etc/init.d/php-fpm-${pv} restart\n\t\t\t\t\t\tfi\n\t\t\t\t\tfi\n\t\t\t\tdone\n\t\t  fi\n        done\n\t\n\tis_ports=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $2}'|xargs)\n\tif [ \"$is_ports\" != '' ];then\n\t\tkill -9 $is_ports\n\t\tsleep 1\n\tfi\n}\n\npanel_stop()\n{\n        echo -e \"Stopping Bt-Tasks...\\c\";\n        get_task_pids\n        arr=($pids)\n        for p in ${arr[@]}\n        do\n                kill -9 $p\n        done\n        echo -e \"\t\\033[32mdone\\033[0m\"\n\n        echo -e \"Stopping Bt-Panel...\\c\";\n\n        get_panel_pids\n        for p in ${arr[@]}\n        do\n                kill -9 $p &>/dev/null\n        done\n        \n        if [ -f $pidfile ];then\n                rm -f $pidfile\n        fi\n        echo -e \"\t\\033[32mdone\\033[0m\"\n}\n\npanel_status()\n{\n        port=$(cat $panel_path/data/port.pl)\n        get_panel_pids\n        if [ \"$isStart\" != '' ];then\n                echo -e \"\\033[32mBt-Panel (pid $(echo $isStart)) already running\\033[0m\"\n        else\n                echo -e \"\\033[31mBt-Panel not running\\033[0m\"\n        fi\n        \n        get_task_pids\n        if [ \"$isStart\" != '' ];then\n                echo -e \"\\033[32mBt-Task (pid $isStart) already running\\033[0m\"\n        else\n                echo -e \"\\033[31mBt-Task not running\\033[0m\"\n        fi\n}\n\npanel_reload()\n{\n\tisStart=$(ps aux|grep 'runserver:app'|grep -v grep|awk '{print $2}')\n        if [ \"$isStart\" != '' ];then\n\t\tkill -9 $isStart\n\t\tsleep 0.5\n\tfi\n\tget_panel_pids\n        if [ \"$isStart\" != '' ];then\n    \t\n\t    get_panel_pids\n\tfor p in ${arr[@]}\n        do\n                kill -9 $p\n        done\n\t\trm -f $pidfile\n\t\tpanel_port_check\n\t\techo -e \"Reload Bt-Panel.\\c\";\n                nohup $panel_path/BT-Panel >> $log_file 2>&1 &\n\t\tisStart=\"\"\n\t\tn=0\n\t\twhile [[ \"$isStart\" == \"\" ]];\n\t\tdo\n\t\t\techo -e \".\\c\"\n\t\t\tsleep 0.5\n\t\t\tget_panel_pids\n\t\t\tlet n+=1\n\t\t\tif [ $n -gt 8 ];then\n\t\t\t\tbreak;\n\t\t\tfi\n\t\tdone\n        if [ \"$isStart\" == '' ];then\n                echo -e \"\\033[31mfailed\\033[0m\"\n                echo '------------------------------------------------------'\n                tail -n 20 $log_file\n                echo '------------------------------------------------------'\n                echo -e \"\\033[31mError: BT-Panel service startup failed.\\033[0m\"\n                return;\n        fi\n        echo -e \"\t\\033[32mdone\\033[0m\"\n    else\n        echo -e \"\\033[31mBt-Panel not running\\033[0m\"\n        panel_start\n    fi\n}\n\ninstall_used()\n{\n        if [ ! -f $panel_path/aliyun.pl ];then\n                return;\n        fi\n        password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 12)\n        username=$($pythonV $panel_path/tools.py panel $password)\n        safe_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)\n        echo \"$safe_path\" > $panel_path/admin_path.pl\n        echo \"$password\" > $panel_path/default.pl\n        rm -f $panel_path/aliyun.pl\n}\n\nerror_logs()\n{\n\ttail -n 100 $log_file\n}\n\n\ncase \"$1\" in\n        'start')\n                install_used\n                panel_start\n                ;;\n        'stop')\n                panel_stop\n                ;;\n        'restart')\n                panel_stop\n\t\t\t\tsleep 1\n                panel_start\n                ;;\n        'reload')\n                panel_reload\n                ;;\n        'status')\n                panel_status\n                ;;\n        'logs')\n        \t\terror_logs\n        \t\t;;\n        'panel')\n        \t\t$pythonV $panel_path/tools.py cli $2\n        \t\t;;\n        'default')\n                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)\n                port=$(cat $panel_path/data/port.pl)\n                password=$(cat $panel_path/default.pl)\n                if [ -f $panel_path/data/domain.conf ];then\n                \taddress=$(cat $panel_path/data/domain.conf)\n                fi\n                if [ -f $panel_path/data/admin_path.pl ];then\n                \tauth_path=$(cat $panel_path/data/admin_path.pl)\n                fi\n                if [ \"$address\" = \"\" ];then\n                \taddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)\n                fi\n\t\t\t\tpool=http\n\t\t\t\tif [ -f $panel_path/data/ssl.pl ];then\n\t\t\t\t\tpool=https\n\t\t\t\tfi\n                echo -e \"==================================================================\"\n                echo -e \"\\033[32mBT-Panel default info!\\033[0m\"\n                echo -e \"==================================================================\"\n                echo  \"外网面板地址: $pool://$address:$port$auth_path\"\n                echo  \"内网面板地址: http://${LOCAL_IP}:$port$auth_path\"\n                echo -e \"\\033[33m*以下仅为初始默认账户密码，若无法登录请执行bt命令重置账户/密码登录\\033[0m\"\n                echo -e `$pythonV $panel_path/tools.py username`\n                echo -e \"password: $password\"\n                echo -e \"\\033[33mIf you cannot access the panel,\\033[0m\"\n                echo -e \"\\033[33mrelease the following panel port [${port}] in the security group\\033[0m\"\n                echo -e \"\\033[33m若无法访问面板，请检查防火墙/安全组是否有放行面板[${port}]端口\\033[0m\"\n                echo -e \"==================================================================\"\n                ;;\n        *)\n                $pythonV $panel_path/tools.py cli $1\n        ;;\nesac\n"
  },
  {
    "path": "install/update6.sh",
    "content": "#!/bin/bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\nLANG=en_US.UTF-8\n\nif [ ! -d /www/server/panel/BTPanel ];then\n\techo \"=============================================\"\n\techo \"错误, 5.x不可以使用此命令升级!\"\n\techo \"5.9平滑升级到6.0的命令：curl http://download.bt.cn/install/update_to_6.sh|bash\"\n\texit 0;\nfi\n\npublic_file=/www/server/panel/install/public.sh\npublicFileMd5=$(md5sum ${public_file} 2>/dev/null|awk '{print $1}')\nmd5check=\"918CC0E14AC92F9D51BFD5CE6A076C36\"\nif [ \"${publicFileMd5}\" != \"${md5check}\"  ]; then\n\twget -O Tpublic.sh https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/public.sh -T 20;\n\tpublicFileMd5=$(md5sum Tpublic.sh 2>/dev/null|awk '{print $1}')\n\tif [ \"${publicFileMd5}\" == \"${md5check}\"  ]; then\n\t\t\\cp -rpa Tpublic.sh $public_file\n\tfi\n\trm -f Tpublic.sh\nfi\n. $public_file\n\nCentos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')\nif [ \"${Centos8Check}\" ];then\n\tif [ ! -f \"/usr/bin/python\" ] && [ -f \"/usr/bin/python3\" ] && [ ! -d \"/www/server/panel/pyenv\" ]; then\n\t\tln -sf /usr/bin/python3 /usr/bin/python\n\tfi\nfi\n\nmypip=\"pip\"\nenv_path=/www/server/panel/pyenv/bin/activate\nif [ -f $env_path ];then\n\tmypip=\"/www/server/panel/pyenv/bin/pip\"\nfi\n\ndownload_Url=$NODE_URL\nsetup_path=/www\nversion=$(curl -Ss --connect-timeout 5 -m 2 https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/api/panel/get_version)\nif [ \"$version\" = '' ];then\n\tversion='7.7.0'\nfi\narmCheck=$(uname -m|grep arm)\nif [ \"${armCheck}\" ];then\n\tversion='7.7.0'\nfi\nwget -T 5 -O /tmp/panel.zip https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/LinuxPanel-7.7.0.zip\ndsize=$(du -b /tmp/panel.zip|awk '{print $1}')\nif [ $dsize -lt 10240 ];then\n\techo \"获取更新包失败，请稍后更新或联系宝塔运维\"\n\texit;\nfi\nunzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null\nrm -f /tmp/panel.zip\ncd $setup_path/server/panel/\ncheck_bt=`cat /etc/init.d/bt`\nif [ \"${check_bt}\" = \"\" ];then\n\trm -f /etc/init.d/bt\n\twget -O /etc/init.d/bt https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/bt6.init -T 20\n\tchmod +x /etc/init.d/bt\nfi\nrm -f /www/server/panel/*.pyc\nrm -f /www/server/panel/class/*.pyc\n#pip install flask_sqlalchemy\n#pip install itsdangerous==0.24\n\npip_list=$($mypip list)\nrequest_v=$(echo \"$pip_list\"|grep requests)\nif [ \"$request_v\" = \"\" ];then\n\t$mypip install requests\nfi\nopenssl_v=$(echo \"$pip_list\"|grep pyOpenSSL)\nif [ \"$openssl_v\" = \"\" ];then\n\t$mypip install pyOpenSSL\nfi\n\n#cffi_v=$(echo \"$pip_list\"|grep cffi|grep 1.12.)\n#if [ \"$cffi_v\" = \"\" ];then\n#\t$mypip install cffi==1.12.3\n#fi\n\npymysql=$(echo \"$pip_list\"|grep pymysql)\nif [ \"$pymysql\" = \"\" ];then\n\t$mypip install pymysql\nfi\n\npymysql=$(echo \"$pip_list\"|grep pycryptodome)\nif [ \"$pymysql\" = \"\" ];then\n\t$mypip install pycryptodome\nfi\n\n#psutil=$(echo \"$pip_list\"|grep psutil|awk '{print $2}'|grep '5.7.')\n#if [ \"$psutil\" = \"\" ];then\n#\t$mypip install -U psutil\n#fi\n\nif [ -d /www/server/panel/class/BTPanel ];then\n\trm -rf /www/server/panel/class/BTPanel\nfi\n\nchattr -i /etc/init.d/bt\nchmod +x /etc/init.d/bt\necho \"=====================================\"\nrm -f /dev/shm/bt_sql_tips.pl\nkill $(ps aux|grep -E \"task.pyc|main.py\"|grep -v grep|awk '{print $2}')\n/etc/init.d/bt start\necho 'True' > /www/server/panel/data/restart.pl\npkill -9 gunicorn &\necho \"已成功升级到[$version]${Ver}\";\n\n\n"
  },
  {
    "path": "install/update6_en.sh",
    "content": "#!/bin/bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\nLANG=en_US.UTF-8\n\nif [ ! -d /www/server/panel/BTPanel ];then\n\techo \"=============================================\"\n\techo \"Error, 5.x Can't use this command to upgrade!\"\n\t#echo \"5.9 Smooth upgrade to 6.0 command：curl http://download.bt.cn/install/update_to_6.sh|bash\"\n\texit 0;\nfi\n\npublic_file=/www/server/panel/install/public.sh\npublicFileMd5=$(md5sum ${public_file} 2>/dev/null|awk '{print $1}')\nmd5check=\"918CC0E14AC92F9D51BFD5CE6A076C36\"\nif [ \"${publicFileMd5}\" != \"${md5check}\"  ]; then\n\twget -O Tpublic.sh https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/public.sh -T 20;\n\tpublicFileMd5=$(md5sum Tpublic.sh 2>/dev/null|awk '{print $1}')\n\tif [ \"${publicFileMd5}\" == \"${md5check}\"  ]; then\n\t\t\\cp -rpa Tpublic.sh $public_file\n\tfi\n\trm -f Tpublic.sh\nfi\n. $public_file\n\nCentos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')\nif [ \"${Centos8Check}\" ];then\n\tif [ ! -f \"/usr/bin/python\" ] && [ -f \"/usr/bin/python3\" ] && [ ! -d \"/www/server/panel/pyenv\" ]; then\n\t\tln -sf /usr/bin/python3 /usr/bin/python\n\tfi\nfi\n\nmypip=\"pip\"\nenv_path=/www/server/panel/pyenv/bin/activate\nif [ -f $env_path ];then\n\tmypip=\"/www/server/panel/pyenv/bin/pip\"\nfi\n\ndownload_Url=$NODE_URL\nsetup_path=/www\nversion=$(curl -Ss --connect-timeout 5 -m 2 https://brandnew.aapanel.com/api/panel/getLatestOfficialVersion)\nif [ \"$version\" = '' ];then\n\tversion='6.8.16'\nfi\nwget -T 5 -O /tmp/panel.zip https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/LinuxPanel-7.7.0.zip\ndsize=$(du -b /tmp/panel.zip|awk '{print $1}')\nif [ $dsize -lt 10240 ];then\n\techo \"Failed to get update package, please update or contact aaPanel Operation\"\n\texit;\nfi\nunzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null\nrm -f /tmp/panel.zip\ncd $setup_path/server/panel/\ncheck_bt=`cat /etc/init.d/bt`\nif [ \"${check_bt}\" = \"\" ];then\n\trm -f /etc/init.d/bt\n\twget -O /etc/init.d/bt https://raw.githubusercontent.com/zhucaidan/btpanel-v7.7.0/main/install/src/bt6.init -T 20\n\tchmod +x /etc/init.d/bt\nfi\nrm -f /www/server/panel/*.pyc\nrm -f /www/server/panel/class/*.pyc\n#pip install flask_sqlalchemy\n#pip install itsdangerous==0.24\npip_list=$($mypip list)\nrequest_v=$(echo \"$pip_list\"|grep requests)\nif [ \"$request_v\" = \"\" ];then\n\t$mypip install requests\nfi\nopenssl_v=$(echo \"$pip_list\"|grep pyOpenSSL)\nif [ \"$openssl_v\" = \"\" ];then\n\t$mypip install pyOpenSSL\nfi\n\ncffi_v=$(echo \"$pip_list\"|grep cffi|grep 1.12.)\nif [ \"$cffi_v\" = \"\" ];then\n\t$mypip install cffi==1.12.3\nfi\npymysql=$(echo \"$pip_list\"|grep pymysql)\nif [ \"$pymysql\" = \"\" ];then\n\t$mypip install pymysql\nfi\n\npsutil=$(echo \"$pip_list\"|grep psutil|awk '{print $2}'|grep '5.7.')\nif [ \"$psutil\" = \"\" ];then\n\t$mypip install -U psutil\nfi\n$mypip install telegram\n$mypip install paramiko -I\nRun_User=\"www\"\ngroupadd ${Run_User}\nuseradd -s /sbin/nologin -g ${Run_User} ${Run_User}\nchattr -i /etc/init.d/bt\nchmod +x /etc/init.d/bt\necho \"=====================================\"\nrm -f /dev/shm/bt_sql_tips.pl\nkill $(ps aux|grep -E \"task.pyc|main.py\"|grep -v grep|awk '{print $2}')\n#/etc/init.d/bt restart\n#echo 'True' > /www/server/panel/data/restart.pl\necho \"Successfully upgraded to[$version]${Ver}\";\n\n\n"
  },
  {
    "path": "install/yumRepo_select.sh",
    "content": "#!/bin/bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\nget_Yum_Repo(){\n\tnodes=(http://mirrors.cloud.tencent.com/repo/centos7_base.repo http://mirrors.aliyun.com/repo/Centos-7.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo https://mirrors.tuna.tsinghua.edu.cn/help/centos/index.html)\n\ti=1\n\tfor node in ${nodes[@]}; \n\tdo\n\t\tstart=$(date +%s.%N)\n\t\tresult=$(curl --connect-timeout 5 --head -s -o /dev/null -w %{http_code} ${node})\n\t\tif [ \"$result\" == \"200\" ];then\n\t\t\tend=`date +%s.%N`\n\t\t\tstart_s=`echo $start | cut -d '.' -f 1`\n\t\t\tstart_ns=`echo $start | cut -d '.' -f 2`\n\t\t\tend_s=`echo $end | cut -d '.' -f 1`\n\t\t\tend_ns=`echo $end | cut -d '.' -f 2`\n\t\t\ttime_micro=$(( (10#$end_s-10#$start_s)*1000000 + (10#$end_ns/1000 - 10#$start_ns/1000) ))\n\t\t\ttime_ms=$(($time_micro/1000))\n\t\t\tvalues[$i]=$time_ms;\n\t\t\turls[$time_ms]=$node\n\t\t\ti=$(($i+1))\n\t\t\tif [ $time_ms -lt 50 ];then\n\t\t\t\tbreak;\n\t\t\tfi\n\t\tfi\n\tdone\n\tj=5000\n\tfor n in ${values[@]};\n\tdo\n\t\tif [ $j -gt $n ];then\n\t\t\tj=$n\n\t\tfi\n\t\tif [ $j -lt 50 ];then\n\t\t\tbreak;\n\t\tfi\n\tdone\n\tif [ $j = 5000 ];then\n\t\tyumRepo='False';\n\t\tT_HOST='False'\n\telse\n\t\tmv -f /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.Bak \n\t\tyumRepo=${urls[$j]}\n\t\tmy_tmp=$(echo $yumRepo|grep 'tencent')\n\t\tif [ \"$my_tmp\" ];then\n\t\t\twget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo\n\t\telif [ $(echo $yumRepo|grep 'aliyun') ]; then\n\t\t\twget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo\n\t\telif [ $(echo $yumRepo|grep '163') ];then\n\t\t\twget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo\n\t\telif [ $(echo $yumRepo|grep 'tsinghua') ];then\n\t\t\twget -O /etc/yum.repos.d/CentOS-Base.repo http://download.bt.cn/mirrors/repo/Centos7-Base-thu.repo\n\t\tfi\n\t\tyum makecache\n\tfi\n}\ncentos_version=$(cat /etc/redhat-release | grep ' 7.' | grep -i centos)\nif [ \"${centos_version}\" ];then\n\tget_Yum_Repo\nfi\n\n"
  }
]