CF反代非SSL版

此版本脚本不需要SSL!不需要SSL!不需要SSL!
This commit is contained in:
vitaminx 2020-07-08 15:02:04 +08:00 committed by GitHub
parent a30f523f79
commit 8ae95bbb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 235 additions and 93 deletions

167
gdutilsbotinstall.sh Normal file
View File

@ -0,0 +1,167 @@
#!/bin/bash
echo
echo -e "\033[1;32m===== <<gdutils项目一键部署脚本之“TG机器人”>> =====\033[0m"
echo -e "\033[1;32m----------------[ v2.1 by oneking ]----------------\033[0m"
echo -e "\033[32m 01.\033[0m 本脚本是针对TG大神@viegg的gdutils项目“TG机器人”部分一键部署脚本;"
echo -e "\033[32m 02.\033[0m 准备工作一部署完成gdutils项目TD查询转存部分;"
echo -e "\033[32m 03.\033[0m 准备工作二在TG上注册好机器人取得并记录下该机器人TOKEN"
echo -e "\033[32m 04.\033[0m 准备工作三拥有一个域名绑定到cloudflare解析到该机器人所在服务器IP"
echo -e "\033[32m 05.\033[0m 准备工作四:向机器人@userinfobot获取个人TG账号ID并记录"
echo -e "\033[32m 06.\033[0m 准备工作五注册好一个Google team drive加入sa并记录下该盘ID"
echo -e "\033[32m 07.\033[0m 本脚本适应CentOS/Debian/Ubuntu三种操作系统自动识别、自动匹配参数一键部署"
echo -e "\033[32m 08.\033[0m 由于本脚本涉及到依赖软件较多避免中断建议使用screen窗口安装"
echo -e "\033[32m 09.\033[0m 经测试可用完美安装系统Centos 7/8 debian 9/10 ubuntu 16.04/18.04/19.10/20.04"
echo -e "\033[32m 10.\033[0m 部署过程中有任何问题请把“错误截图”“部署VPS系统名称版本”信息发给TGonekings 或 vitaminor@gmail.com"
echo -e "\033[1;32m------------------------------------------------\033[0m"
read -s -n1 -p "★★★ 如已做好以上[2/3/4/5/6]准备请按任意键开始部署如未做好准备请按“Ctrl+c”终止部署 ★★★"
echo
echo -e "\033[1;32m------------------------------------------------\033[0m"
# 识别操作系统
aNAME="$(uname -a)"
bNAME="$(cat /proc/version)"
cNAME="$(lsb_release -a)"
if [ -f "/etc/redhat-release" ]; then
if [[ $(cat /etc/redhat-release) =~ "CentOS" ]]; then
os="CentOS"
fi
elif [ "$aNAME"=~"Debian" -o "$bNAME"=~"Debian" -o "$cNAME"=~"Debian" ]; then
os="Debian"
elif [ "$aNAME"=~"Ubuntu" -o "$bNAME"=~"Ubuntu" -o "$cNAME"=~"Ubuntu" ]; then
os="Debian"
elif [ "$aNAME"=~"CentOS" -o "$bNAME"=~"CentOS" -o "$cNAME"=~"CentOS" ]; then
os="CentOS"
elif [ "$aNAME"=~"Darwin" -o "$bNAME"=~"Darwin" -o "$cNAME"=~"Darwin" ]; then
os="mac"
else
os="$bNAME"
fi
#根据操作系统设置变量
if [[ "$os" = "Debian" ]]; then
cmd_install="apt-get" #安装命令
nginx_conf="/etc/nginx/sites-enabled/" #nginx配置文件存放路径
rm_nginx_default="rm -f /etc/nginx/sites-enabled/default" #删除default
echo
echo -e "\033[1;32m★★★★★ 您的操作系统为Debian即将为你开始自动部署gdutils项目“TG机器人”部分 ★★★★★\033[0m"
elif [[ "$os" = "Ubuntu" ]]; then
cmd_install="sudo apt-get"
nginx_conf="/etc/nginx/sites-enabled/"
rm_nginx_default="rm -f /etc/nginx/sites-enabled/default"
echo
echo -e "\033[1;32m★★★★★ 您的操作系统为Ubuntu即将为你开始自动部署gdutils项目“TG机器人”部分 ★★★★★\033[0m"
elif [[ "$os" = "CentOS" ]]; then
cmd_install="yum"
nginx_conf="/etc/nginx/conf.d/"
rm_nginx_default=""
echo
echo -e "\033[1;32m★★★★★ 您的操作系统为Centos即将为你开始自动部署gdutils项目“TG机器人”部分 ★★★★★\033[0m"
elif [[ "$os" = "mac" ]]; then
echo
echo -e "\033[1;32m★★★★★ 您的操作系统为MacOS请在图形界面手动部署 ★★★★★\033[0m"
exit
echo
echo
else
echo
echo -e "\033[1;32m unknow os $OS, exit! \033[0m"
exit
echo
echo
fi
echo -e "\033[1;32m----------------------------------------------------------\033[0m"
#输入“机器人token/TG账号ID/域名/转存目的盘ID”
read -p """请输入机器人token并回车
Your Bot Token =>:""" YOUR_BOT_TOKEN
#判断token是否输入正确
while [[ "${#YOUR_BOT_TOKEN}" != 46 ]]; do
echo -e "\033[1;32m★★★ 机器人TOKEN输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m"
read -p """请输入机器人token并回车
Your Bot Token =>:""" YOUR_BOT_TOKEN
done
read -p """请输入你的域名(在cloudflare上解析到你机器人所在VPS的域名格式bot.abc.com)并回车
Your Domain Name =>:""" YOUR_DOMAIN_NAME
#判断域名是否正确
while [[ "$YOUR_DOMAIN_NAME" =~ "http" ]]; do
echo -e "\033[1;32m★★★ “Your Domain Name”输入错误应该输入你在cloudflare上解析的域名且不包含“http”请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m"
read -p """请输入你的域名(在cloudflare上解析到你机器人所在VPS的域名格式bot.abc.com)并回车
Your Domain Name =>:""" YOUR_DOMAIN_NAME
done
read -p """请输入使用机器人的telegram账号ID(获取ID机器人@userinfobot)并回车
Your Telegram ID =>:""" YOUR_TELEGRAM_ID
#判断telegram ID是否正确(通过判断是不是纯数字)
until [[ $YOUR_TELEGRAM_ID =~ ^-?[0-9]+$ ]]; do
echo -e "\033[1;32m★★★ 您的TG账号ID输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m"
read -p """请输入使用机器人的telegram账号ID(获取ID机器人@userinfobot)并回车
Your Telegram ID =>:""" YOUR_TELEGRAM_ID
done
read -p """请输入转存默认目的地团队盘ID(不指定转存目的地默认改地址脚本强制要求输入团队盘ID)并回车
Your Google Team Drive ID =>:""" YOUR_GOOGLE_TEAM_DRIVE_ID
#判断google team drive ID是否正确团队盘ID长度19位
while [[ "${#YOUR_GOOGLE_TEAM_DRIVE_ID}" != 19 ]]; do
echo -e "\033[1;32m★★★ 您的Google team drive ID输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m"
read -p """请输入转存默认目的地ID(不指定转存目的地默认该地址脚本强制要求输入团队盘ID)并回车
Your Google Team Drive ID =>:""" YOUR_GOOGLE_TEAM_DRIVE_ID
done
cd ~ &&
sed -i "s/bot_token/$YOUR_BOT_TOKEN/g" ./gd-utils/config.js &&
sed -i "s/your_tg_username/$YOUR_TELEGRAM_ID/g" ./gd-utils/config.js &&
sed -i "s/DEFAULT_TARGET = ''/DEFAULT_TARGET = '$YOUR_GOOGLE_TEAM_DRIVE_ID'/g" ./gd-utils/config.js
echo -e "\033[1;32m----------------------------------------------------------\033[0m"
echo -e "\033[1;32m“进程守护程序pm2”开始安装......\033[0m"
cd /root/gd-utils &&
npm i pm2 -g && pm2 l
echo -e "\033[1;32m启动守护进程......\033[0m"
pm2 start server.js
echo -e "\033[1;32m----------------------------------------------------------\033[0m"
echo -e "\033[1;32m“nginx”开始安装......\033[0m"
cd ~ &&
$cmd_install install nginx -y
echo
echo -e "\033[1;32m===== <<配置nginx服务>> ===== \033[0m"
echo
echo -e "\033[1;32m“nginx”起一个web服务......\033[0m"
cd $nginx_conf
echo "server {
listen 80;
server_name $YOUR_DOMAIN_NAME;
location / {
proxy_pass http://127.0.0.1:23333/;
}
}" >${nginx_conf}gdutilsbot.conf &&
$rm_nginx_default
ls &&
nginx -t &&
nginx -c /etc/nginx/nginx.conf &&
nginx -s reload &&
netstat -tulpen
echo -e "\033[1;32m----------------------------------------------------------\033[0m"
echo -e "\033[1;32m“检查网站是否部署成功”......\033[0m"
curl $YOUR_DOMAIN_NAME/api/gdurl/count\?fid=124pjM5LggSuwI1n40bcD5tQ13wS0M6wg
echo
echo -e "\033[1;32m设置Webhook服务......\033[0m"
print_webhook=$(curl -F "url=https://$YOUR_DOMAIN_NAME/api/gdurl/tgbot" "https://api.telegram.org/bot$YOUR_BOT_TOKEN/setWebhook")
echo
# 判断反向代理是否部署成功
if [[ $print_webhook =~ "true" ]]; then
echo -e "\033[1;32m★★★ 恭喜你GoogleDrive查询转存机器人部署成功请回到TG界面给bot发送个“/help”获取使用帮助 ★★★\033[0m"
else
echo -e "\033[32m★★★ 很遗憾!机器人设置失败,请返回检查网站是否部署成功,并重复本安装过程 ★★★\033[0m", exit!
fi
nginx -t && nginx -s reload
echo
echo
cd ~
rm -f gdutilsbotinstall.sh

View File

@ -1,21 +1,24 @@
#!/bin/bash #!"C:\Program Files\Git\usr\bin\bash"
echo #/bin/bash
echo -e "\033[1;32m===== <<gdutils项目一件部署脚本要求及说明>> =====\033[0m" #颜色变量,因为颜色字符复杂,定义一个函数表示其代码字符串能够很好容错,更改也方便
echo -e "\033[1;32m---------------[ v2.1 by oneking ]---------------\033[0m" color_yellow='\033[1;32m'
echo -e "\033[32m 01.\033[0m 本脚本是针对TG大神@viegg的gdutils项目一键部署脚本;" color_end='\033[0m'
echo -e "\033[32m 02.\033[0m 脚本包括“TD盘VPS上查询转存部署”和“Telegram机器人部署”两部分"
echo -e "\033[32m 03.\033[0m 本脚本适应CentOS/Debian/Ubuntu三种操作系统自动识别、自动选择对应分支一键安装部署" echo -e "\n$color_yellow===== <<gdutils项目一件部署脚本要求及说明>> =====$color_end"
echo -e "\033[32m 04.\033[0m 三步即可完成部署上传脚本到VPS → 设置脚本执行权限 → 运行" echo -e "$color_yellow---------------[ v2.1 by oneking ]---------------$color_end"
echo -e "\033[32m 05.\033[0m 准备工作一在TG上注册好机器人取得并记录下该机器人TOKEN" echo -e "$color_yellow 01.$color_end 本脚本是针对TG大神@viegg的gdutils项目一键部署脚本;"
echo -e "\033[32m 06.\033[0m 准备工作二拥有一个域名绑定到cloudflare解析到该机器人所在服务器IP" echo -e "$color_yellow 02.$color_end 脚本包括“TD盘VPS上查询转存部署”和“Telegram机器人部署”两部分"
echo -e "\033[32m 07.\033[0m 准备工作三:向机器人@userinfobot获取个人TG账号ID并记录" echo -e "$color_yellow 03.$color_end 本脚本适应CentOS/Debian/Ubuntu三种操作系统自动识别、自动选择对应分支一键安装部署"
echo -e "\033[32m 08.\033[0m 准备工作四注册好一个Google team drive加入sa并记录下该盘ID" echo -e "$color_yellow 04.$color_end 三步即可完成部署上传脚本到VPS → 设置脚本执行权限 → 运行"
echo -e "\033[32m 09.\033[0m 经测试可用完美安装系统Centos 7/8 debian 9/10 ubuntu 16.04/18.04/19.10/20.04" echo -e "$color_yellow 05.$color_end 准备工作一在TG上注册好机器人取得并记录下该机器人TOKEN"
echo -e "\033[32m 10.\033[0m 部署过程中有任何问题请把“错误截图”“部署VPS系统名称版本”信息发给TGonekings 或 vitaminor@gmail.com" echo -e "$color_yellow 06.$color_end 准备工作二拥有一个域名绑定到cloudflare解析到该机器人所在服务器IP"
echo -e "\033[1;32m------------------------------------------------\033[0m" echo -e "$color_yellow 07.$color_end 准备工作三:向机器人@userinfobot获取个人TG账号ID并记录"
echo -e "$color_yellow 08.$color_end 准备工作四注册好一个Google team drive加入sa并记录下该盘ID"
echo -e "$color_yellow 09.$color_end 经测试可用完美安装系统Centos 7/8 debian 9/10 ubuntu 16.04/18.04/19.10/20.04"
echo -e "$color_yellow 10.$color_end 部署过程中有任何问题请把“错误截图”“部署VPS系统名称版本”信息发给TGonekings 或 vitaminor@gmail.com"
echo -e "$color_yellow------------------------------------------------$color_end"
read -s -n1 -p "★★★ 如已做好以上[5/6/7/8]准备或不需要安装Telegram机器人请按任意键开始部署如未做好准备请按“Ctrl+c”终止脚本 ★★★" read -s -n1 -p "★★★ 如已做好以上[5/6/7/8]准备或不需要安装Telegram机器人请按任意键开始部署如未做好准备请按“Ctrl+c”终止脚本 ★★★"
echo echo -e "\n$color_yellow------------------------------------------------$color_end"
echo -e "\033[1;32m------------------------------------------------\033[0m"
# 识别操作系统 # 识别操作系统
aNAME="$(uname -a)" aNAME="$(uname -a)"
@ -49,7 +52,7 @@ if [[ "$os" = "Debian" ]]; then
nginx_conf="/etc/nginx/sites-enabled/" #nginx配置文件存放路径 nginx_conf="/etc/nginx/sites-enabled/" #nginx配置文件存放路径
rm_nginx_default="rm -f /etc/nginx/sites-enabled/default" #删除default rm_nginx_default="rm -f /etc/nginx/sites-enabled/default" #删除default
echo echo
echo -e "\033[1;32m★★★★★ 您的操作系统为Debian即将为你开始部署gdutils项目 ★★★★★\033[0m" echo -e "$color_yellow★★★★★ 您的操作系统为Debian即将为你开始部署gdutils项目 ★★★★★$color_end"
elif [[ "$os" = "Ubuntu" ]]; then elif [[ "$os" = "Ubuntu" ]]; then
cmd_install="sudo apt-get" cmd_install="sudo apt-get"
cmd_install_rely="build-essential" cmd_install_rely="build-essential"
@ -57,8 +60,7 @@ elif [[ "$os" = "Ubuntu" ]]; then
cmd_install_rpm_build="" cmd_install_rpm_build=""
nginx_conf="/etc/nginx/sites-enabled/" nginx_conf="/etc/nginx/sites-enabled/"
rm_nginx_default="rm -f /etc/nginx/sites-enabled/default" rm_nginx_default="rm -f /etc/nginx/sites-enabled/default"
echo echo -e "\n$color_yellow★★★★★ 您的操作系统为Ubuntu即将为你开始部署gdutils项目 ★★★★★$color_end"
echo -e "\033[1;32m★★★★★ 您的操作系统为Ubuntu即将为你开始部署gdutils项目 ★★★★★\033[0m"
elif [[ "$os" = "CentOS" ]]; then elif [[ "$os" = "CentOS" ]]; then
cmd_install="yum" cmd_install="yum"
cmd_install_rely="gcc-c++ make" cmd_install_rely="gcc-c++ make"
@ -66,82 +68,66 @@ elif [[ "$os" = "CentOS" ]]; then
cmd_install_rpm_build="yum install rpm-build -y" cmd_install_rpm_build="yum install rpm-build -y"
nginx_conf="/etc/nginx/conf.d/" nginx_conf="/etc/nginx/conf.d/"
rm_nginx_default="" rm_nginx_default=""
echo echo -e "\n$color_yellow★★★★★ 您的操作系统为Centos即将为你开始部署gdutils项目 ★★★★★$color_end"
echo -e "\033[1;32m★★★★★ 您的操作系统为Centos即将为你开始部署gdutils项目 ★★★★★\033[0m"
elif [[ "$os" = "mac" ]]; then elif [[ "$os" = "mac" ]]; then
echo echo -e "\n$color_yellow★★★★★ 您的操作系统为MacOS请在图形界面手动安装 ★★★★★$color_end\n" && exit
echo -e "\033[1;32m★★★★★ 您的操作系统为MacOS请在图形界面手动安装 ★★★★★\033[0m"
exit
echo
echo
else else
echo echo -e "\n$color_yellow unknow os $OS, exit! $color_end" && exit
echo -e "\033[1;32m unknow os $OS, exit! \033[0m"
exit
echo
echo
fi fi
echo echo -e "\n$color_yellow===== <<升级系统/更新软件/安装工具/安装依赖>> =====$color_end\n"
echo -e "\033[1;32m===== <<升级系统/更新软件/安装工具/安装依赖>> =====\033[0m"
echo
#安装which和sudo #安装which和sudo
if [[ "$(which which)" == "" ]]; then if [[ "$(which which)" == "" ]]; then
echo -e "\033[1;32m“which”开始安装......\033[0m" echo -e "$color_yellow“which”开始安装......$color_end"
$cmd_install install which -y $cmd_install install which -y
echo -e "\033[1;32m------------------------------------------------\033[0m" echo -e "$color_yellow------------------------------------------------$color_end"
elif [[ "$(which sudo)" == "" ]]; then elif [[ "$(which sudo)" == "" ]]; then
echo -e "\033[1;32m“sudo”开始安装......\033[0m" echo -e "$color_yellow“sudo”开始安装......$color_end"
$cmd_install install sudo -y $cmd_install install sudo -y
echo -e "\033[1;32m------------------------------------------------\033[0m" echo -e "$color_yellow------------------------------------------------$color_end"
fi fi
#安装工具和依赖 #安装工具和依赖
for ((aloop = 0; aloop < ${#insofts[@]}; aloop++)); do for ((aloop = 0; aloop < ${#insofts[@]}; aloop++)); do
if [ ${insofts[$aloop]} = "update" -o ${insofts[$aloop]} = "upgrade" ]; then if [ ${insofts[$aloop]} = "update" -o ${insofts[$aloop]} = "upgrade" ]; then
echo -e "\033[1;32m${insofts[$aloop]}”开始安装......\033[0m" echo -e "$color_yellow${insofts[$aloop]}”开始安装......$color_end"
$cmd_install ${insofts[$aloop]} -y $cmd_install ${insofts[$aloop]} -y
echo -e "\033[1;32m------------------------------------------------\033[0m" echo -e "$color_yellow------------------------------------------------$color_end"
else else
echo -e "\033[1;32m${insofts[$aloop]}”开始安装......\033[0m" echo -e "$color_yellow${insofts[$aloop]}”开始安装......$color_end"
$cmd_install install ${insofts[$aloop]} -y $cmd_install install ${insofts[$aloop]} -y
echo -e "\033[1;32m------------------------------------------------\033[0m" echo -e "$color_yellow------------------------------------------------$color_end"
fi fi
done done
echo echo -e "\n$color_yellow===== <<安装gdutils依赖-nodejs和npm/安装配置gdutils>> =====$color_end\n"
echo -e "\033[1;32m===== <<安装gdutils依赖-nodejs和npm/安装配置gdutils>> =====\033[0m"
echo
$cmd_install install $cmd_install_rely -y $cmd_install install $cmd_install_rely -y
curl -sL $nodejs_curl | bash - curl -sL $nodejs_curl | bash -
$cmd_install install nodejs -y $cmd_install install nodejs -y
$cmd_install_rpm_build $cmd_install_rpm_build
git clone https://github.com/liaojack8/gd-utils-cht && cd gd-utils-cht git clone https://github.com/iwestlin/gd-utils && cd gd-utils
npm config set unsafe-perm=true npm config set unsafe-perm=true
npm i npm i
echo echo -e "\n$color_yellow★★★ 恭喜您!gdutils统计转存系统已经正确安装完成请上传sa到“./gd-utils/sa/”目录下完成最后的配置 ★★★$color_end\n"
echo -e "\033[1;32m★★★ 恭喜您!gdutils统计转存系统已经正确安装完成请上传sa到“./gd-utils-cht/sa/”目录下完成最后的配置 ★★★\033[0m"
echo
################################################################################################# #################################################################################################
echo -e "\033[1;32m----------------------------------------------------------\033[0m" echo -e "$color_yellow----------------------------------------------------------$color_end"
read -s -n1 -p "★★★ 下面将部署Telegram机器人请确保准备所需条件已准备好按任意键开始部署机器人如未做好准备请按“Ctrl+c”终止部署机器人 ★★★" read -s -n1 -p "★★★ 下面将部署Telegram机器人请确保准备所需条件已准备好按任意键开始部署机器人如未做好准备请按“Ctrl+c”终止部署机器人 ★★★"
echo
echo -e "\033[1;32m----------------------------------------------------------\033[0m"
echo echo -e "\n$color_yellow----------------------------------------------------------$color_end"
echo -e "\033[1;32m ===== <<开始部署gdutils查询转存TG机器人>> ===== \033[0m"
echo echo -e "\n$color_yellow ===== <<开始部署gdutils查询转存TG机器人>> ===== $color_end\n"
#输入“机器人token/TG账号ID/域名/转存目的盘ID” #输入“机器人token/TG账号ID/域名/转存目的盘ID”
read -p """请输入机器人token并回车 read -p """请输入机器人token并回车
Your Bot Token =>:""" YOUR_BOT_TOKEN Your Bot Token =>:""" YOUR_BOT_TOKEN
#判断token是否输入正确 #判断token是否输入正确
while [[ "${#YOUR_BOT_TOKEN}" != 46 ]]; do while [[ "${#YOUR_BOT_TOKEN}" != 46 ]]; do
echo -e "\033[1;32m★★★ 机器人TOKEN输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m" echo -e "$color_yellow★★★ 机器人TOKEN输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★$color_end"
read -p """请输入机器人token并回车 read -p """请输入机器人token并回车
Your Bot Token =>:""" YOUR_BOT_TOKEN Your Bot Token =>:""" YOUR_BOT_TOKEN
done done
@ -150,7 +136,7 @@ read -p """请输入你的域名(在cloudflare上解析到你机器人所在VPS
Your Domain Name =>:""" YOUR_DOMAIN_NAME Your Domain Name =>:""" YOUR_DOMAIN_NAME
#判断域名是否正确 #判断域名是否正确
while [[ "$YOUR_DOMAIN_NAME" =~ "http" ]]; do while [[ "$YOUR_DOMAIN_NAME" =~ "http" ]]; do
echo -e "\033[1;32m★★★ “Your Domain Name”输入错误应该输入你在cloudflare上解析的域名且不包含“http”请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m" echo -e "$color_yellow★★★ “Your Domain Name”输入错误应该输入你在cloudflare上解析的域名且不包含“http”请重新输入或按“Ctrl+C”结束安装 ★★★$color_end"
read -p """请输入你的域名(在cloudflare上解析到你机器人所在VPS的域名格式bot.abc.com)并回车 read -p """请输入你的域名(在cloudflare上解析到你机器人所在VPS的域名格式bot.abc.com)并回车
Your Domain Name =>:""" YOUR_DOMAIN_NAME Your Domain Name =>:""" YOUR_DOMAIN_NAME
done done
@ -159,7 +145,7 @@ read -p """请输入使用机器人的telegram账号ID(获取ID机器人@userinf
Your Telegram ID =>:""" YOUR_TELEGRAM_ID Your Telegram ID =>:""" YOUR_TELEGRAM_ID
#判断telegram ID是否正确(通过判断是不是纯数字) #判断telegram ID是否正确(通过判断是不是纯数字)
until [[ $YOUR_TELEGRAM_ID =~ ^-?[0-9]+$ ]]; do until [[ $YOUR_TELEGRAM_ID =~ ^-?[0-9]+$ ]]; do
echo -e "\033[1;32m★★★ 您的TG账号ID输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m" echo -e "$color_yellow★★★ 您的TG账号ID输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★$color_end"
read -p """请输入使用机器人的telegram账号ID(获取ID机器人@userinfobot)并回车 read -p """请输入使用机器人的telegram账号ID(获取ID机器人@userinfobot)并回车
Your Telegram ID =>:""" YOUR_TELEGRAM_ID Your Telegram ID =>:""" YOUR_TELEGRAM_ID
done done
@ -168,44 +154,36 @@ read -p """请输入转存默认目的地团队盘ID(不指定转存目的地默
Your Google Team Drive ID =>:""" YOUR_GOOGLE_TEAM_DRIVE_ID Your Google Team Drive ID =>:""" YOUR_GOOGLE_TEAM_DRIVE_ID
#判断google team drive ID是否正确团队盘ID长度19位 #判断google team drive ID是否正确团队盘ID长度19位
while [[ "${#YOUR_GOOGLE_TEAM_DRIVE_ID}" != 19 ]]; do while [[ "${#YOUR_GOOGLE_TEAM_DRIVE_ID}" != 19 ]]; do
echo -e "\033[1;32m★★★ 您的Google team drive ID输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★\033[0m" echo -e "$color_yellow★★★ 您的Google team drive ID输入不正确请重新输入或按“Ctrl+C”结束安装 ★★★$color_end"
read -p """请输入转存默认目的地ID(不指定转存目的地默认该地址脚本强制要求输入团队盘ID)并回车 read -p """请输入转存默认目的地ID(不指定转存目的地默认该地址脚本强制要求输入团队盘ID)并回车
Your Google Team Drive ID =>:""" YOUR_GOOGLE_TEAM_DRIVE_ID Your Google Team Drive ID =>:""" YOUR_GOOGLE_TEAM_DRIVE_ID
done done
cd ~ && cd ~ &&
sed -i "s/bot_token/$YOUR_BOT_TOKEN/g" ./gd-utils-cht/config.js && sed -i "s/bot_token/$YOUR_BOT_TOKEN/g" ./gd-utils/config.js &&
sed -i "s/your_tg_username/$YOUR_TELEGRAM_ID/g" ./gd-utils-cht/config.js && sed -i "s/your_tg_username/$YOUR_TELEGRAM_ID/g" ./gd-utils/config.js &&
sed -i "s/DEFAULT_TARGET = ''/DEFAULT_TARGET = '$YOUR_GOOGLE_TEAM_DRIVE_ID'/g" ./gd-utils-cht/config.js sed -i "s/DEFAULT_TARGET = ''/DEFAULT_TARGET = '$YOUR_GOOGLE_TEAM_DRIVE_ID'/g" ./gd-utils/config.js
echo -e "\033[1;32m----------------------------------------------------------\033[0m" echo -e "$color_yellow----------------------------------------------------------$color_end"
echo -e "\033[1;32m“进程守护程序pm2”开始安装......\033[0m" echo -e "$color_yellow“进程守护程序pm2”开始安装......$color_end"
cd /root/gd-utils-cht && cd /root/gd-utils &&
npm i pm2 -g && pm2 l npm i pm2 -g && pm2 l
echo -e "\033[1;32m启动守护进程......\033[0m" echo -e "$color_yellow启动守护进程......$color_end"
pm2 start server.js --node-args="--max-old-space-size=4096" pm2 start server.js
echo -e "\033[1;32m----------------------------------------------------------\033[0m" echo -e "$color_yellow----------------------------------------------------------$color_end"
echo -e "\033[1;32m“nginx”开始安装......\033[0m" echo -e "$color_yellow“nginx”开始安装......$color_end"
cd ~ && cd ~ &&
$cmd_install install nginx -y $cmd_install install nginx -y
echo echo
echo -e "\033[1;32m===== <<配置nginx服务>> ===== \033[0m" echo -e "$color_yellow===== <<配置nginx服务>> ===== $color_end"
echo echo
echo -e "\033[1;32m“nginx”起一个web服务......\033[0m" echo -e "$color_yellow“nginx”起一个web服务......$color_end"
cd $nginx_conf cd $nginx_conf
echo "server { echo "server {
listen 80; listen 80;
server_name $YOUR_DOMAIN_NAME; server_name $YOUR_DOMAIN_NAME;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl on;
ssl_certificate /etc/ssl/certificate.crt;
ssl_certificate_key /etc/ssl/private.key;
server_name $YOUR_DOMAIN_NAME;
location / { location / {
proxy_pass http://127.0.0.1:23333/; proxy_pass http://127.0.0.1:23333/;
} }
@ -217,24 +195,21 @@ ls &&
nginx -c /etc/nginx/nginx.conf && nginx -c /etc/nginx/nginx.conf &&
nginx -s reload && nginx -s reload &&
netstat -tulpen netstat -tulpen
echo -e "\033[1;32m----------------------------------------------------------\033[0m" echo -e "$color_yellow----------------------------------------------------------$color_end"
echo -e "\033[1;32m“检查网站是否部署成功”......\033[0m" echo -e "$color_yellow“检查网站是否部署成功”......$color_end"
curl $YOUR_DOMAIN_NAME/api/gdurl/count\?fid=124pjM5LggSuwI1n40bcD5tQ13wS0M6wg curl $YOUR_DOMAIN_NAME/api/gdurl/count\?fid=124pjM5LggSuwI1n40bcD5tQ13wS0M6wg
echo echo -e "\n$color_yellow设置Webhook服务......$color_end"
echo -e "\033[1;32m设置Webhook服务......\033[0m"
print_webhook=$(curl -F "url=https://$YOUR_DOMAIN_NAME/api/gdurl/tgbot" "https://api.telegram.org/bot$YOUR_BOT_TOKEN/setWebhook") print_webhook=$(curl -F "url=https://$YOUR_DOMAIN_NAME/api/gdurl/tgbot" "https://api.telegram.org/bot$YOUR_BOT_TOKEN/setWebhook")
echo echo
# 判断反向代理是否部署成功 # 判断反向代理是否部署成功
if [[ $print_webhook =~ "true" ]]; then if [[ $print_webhook =~ "true" ]]; then
echo -e "\033[1;32m★★★ 恭喜你GoogleDrive查询转存机器人部署成功请回到TG界面给bot发送个“/help”获取使用帮助 ★★★\033[0m" echo -e "$color_yellow★★★ 恭喜你GoogleDrive查询转存机器人部署成功请回到TG界面给bot发送个“/help”获取使用帮助 ★★★$color_end"
else else
echo -e "\033[32m★★★ 很遗憾!机器人设置失败,请返回检查网站是否部署成功,并重复本安装过程 ★★★\033[0m", exit! echo -e "$color_yellow★★★ 很遗憾!机器人设置失败,请返回检查网站是否部署成功,并重复本安装过程 ★★★$color_end", exit!
fi fi
nginx -t && nginx -s reload nginx -t && nginx -s reload && \n\n
echo
echo
cd ~ cd ~
rm -f gdutilsinstall.sh rm -f gdutilsinstall.sh