💩 一键脚本修锅 fixed #40 (#41)

This commit is contained in:
KLDGodY 2021-01-02 11:18:06 +08:00 committed by GitHub
parent da2b67336b
commit 2d5386cf85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,8 +40,7 @@ yum_update(){
yum_git_check() {
echo "正在检查 Git 安装情况 . . ."
if command -v git >> /dev/null 2>&1;
then
if command -v git >>/dev/null 2>&1; then
echo "Git 似乎存在,安装过程继续 . . ."
else
echo "Git 未安装在此系统上,正在进行安装"
@ -52,23 +51,23 @@ yum_git_check() {
yum_python_check() {
echo "正在检查 python 安装情况 . . ."
if command -v python3 >>/dev/null 2>&1; then
U_V1=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
U_V2=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $2}'`
U_V1=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}')
U_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}')
if [ $U_V1 -gt 3 ]; then
echo 'Python 3.6+ 存在 . . .'
elif [ $U_V2 -ge 6 ]; then
echo 'Python 3.6+ 存在 . . .'
PYV=$U_V1.$U_V2
PYV=`which python$PYV`
PYV=$(which python$PYV)
else
if command -v python3.6 >>/dev/null 2>&1; then
echo 'Python 3.6+ 存在 . . .'
PYV=`which python3.6`
PYV=$(which python3.6)
else
echo "Python3.6 未安装在此系统上,正在进行安装"
yum install python3 -y >>/dev/null 2>&1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >>/dev/null 2>&1
PYV=`which python3.6`
PYV=$(which python3.6)
fi
fi
else
@ -86,8 +85,7 @@ yum_python_check() {
yum_screen_check() {
echo "正在检查 Screen 安装情况 . . ."
if command -v screen >> /dev/null 2>&1;
then
if command -v screen >>/dev/null 2>&1; then
echo "Screen 似乎存在, 安装过程继续 . . ."
else
echo "Screen 未安装在此系统上,正在进行安装"
@ -114,8 +112,7 @@ apt_update(){
apt_git_check() {
echo "正在检查 Git 安装情况 . . ."
if command -v git >> /dev/null 2>&1;
then
if command -v git >>/dev/null 2>&1; then
echo "Git 似乎存在, 安装过程继续 . . ."
else
echo "Git 未安装在此系统上,正在进行安装"
@ -126,25 +123,25 @@ apt_git_check() {
apt_python_check() {
echo "正在检查 python 安装情况 . . ."
if command -v python3 >>/dev/null 2>&1; then
U_V1=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
U_V2=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $2}'`
U_V1=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}')
U_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}')
if [ $U_V1 -gt 3 ]; then
echo 'Python 3.6+ 存在 . . .'
elif [ $U_V2 -ge 6 ]; then
echo 'Python 3.6+ 存在 . . .'
PYV=$U_V1.$U_V2
PYV=`which python$PYV`
PYV=$(which python$PYV)
else
if command -v python3.6 >>/dev/null 2>&1; then
echo 'Python 3.6+ 存在 . . .'
PYV=`which python3.6`
PYV=$(which python3.6)
else
echo "Python3.6 未安装在此系统上,正在进行安装"
add-apt-repository ppa:deadsnakes/ppa -y
apt-get update >>/dev/null 2>&1
apt-get install python3.6 -y >>/dev/null 2>&1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >>/dev/null 2>&1
PYV=`which python3.6`
PYV=$(which python3.6)
fi
fi
else
@ -165,18 +162,18 @@ apt_python_check() {
debian_python_check() {
echo "正在检查 python 安装情况 . . ."
if command -v python3 >>/dev/null 2>&1; then
U_V1=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
U_V2=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $2}'`
U_V1=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1}')
U_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}')
if [ $U_V1 -gt 3 ]; then
echo 'Python 3.6+ 存在 . . .'
elif [ $U_V2 -ge 6 ]; then
echo 'Python 3.6+ 存在 . . .'
PYV=$U_V1.$U_V2
PYV=`which python$PYV`
PYV=$(which python$PYV)
else
if command -v python3.6 >>/dev/null 2>&1; then
echo 'Python 3.6+ 存在 . . .'
PYV=`which python3.6`
PYV=$(which python3.6)
else
echo "Python3.6 未安装在此系统上,正在进行安装"
apt-get update -y >>/dev/null 2>&1
@ -189,7 +186,7 @@ debian_python_check() {
make && make install >>/dev/null 2>&1
cd .. >>/dev/null 2>&1
rm -rf Python-3.6.5 Python-3.6.5.tar.gz >>/dev/null 2>&1
PYP=`which python3.6`
PYP=$(which python3.6)
update-alternatives --install $PYP python3 $PYV 1 >>/dev/null 2>&1
fi
fi
@ -205,7 +202,7 @@ debian_python_check() {
make && make install >>/dev/null 2>&1
cd .. >>/dev/null 2>&1
rm -rf Python-3.6.5 Python-3.6.5.tar.gz >>/dev/null 2>&1
PYP=`which python3`
PYP=$(which python3)
update-alternatives --install $PYP python3 $PYV 1 >>/dev/null 2>&1
fi
echo "正在检查 pip3 安装情况 . . ."
@ -219,8 +216,7 @@ debian_python_check() {
apt_screen_check() {
echo "正在检查 Screen 安装情况 . . ."
if command -v screen >> /dev/null 2>&1;
then
if command -v screen >>/dev/null 2>&1; then
echo "Screen 似乎存在, 安装过程继续 . . ."
else
echo "Screen 未安装在此系统上,正在进行安装"
@ -268,24 +264,21 @@ configure() {
sed -i "s/HASH_HERE/$api_hash/" $config_file
printf "请输入应用程序语言默认zh-cn"
read -r application_language <&1
if [ -z "$application_language" ]
then
if [ -z "$application_language" ]; then
echo "语言设置为 简体中文"
else
sed -i "s/zh-cn/$application_language/" $config_file
fi
printf "请输入应用程序地区默认China"
read -r application_region <&1
if [ -z "$application_region" ]
then
if [ -z "$application_region" ]; then
echo "地区设置为 中国"
else
sed -i "s/China/$application_region/" $config_file
fi
printf "请输入 Google TTS 语言默认zh-CN"
read -r application_tts <&1
if [ -z "$application_tts" ]
then
if [ -z "$application_tts" ]; then
echo "tts发音语言设置为 简体中文"
else
sed -i "s/zh-CN/$application_tts/" $config_file
@ -296,8 +289,7 @@ configure() {
[yY][eE][sS] | [yY])
printf "请输入您的日志记录群组/频道的 ChatID (如果要发送给 原 PagerMaid 作者 请按Enter"
read -r log_chatid <&1
if [ -z "$log_chatid" ]
then
if [ -z "$log_chatid" ]; then
echo "LOG 将发送到 原 PagerMaid 作者."
else
sed -i "s/503691334/$log_chatid/" $config_file
@ -315,26 +307,29 @@ configure() {
}
read_checknum() {
if [ "$ftime" == "111" ]; then
echo "失败次数达到上限!" && exit 1
fi
while :; do
read -p "请输入您的登录验证码: " checknum
if [ "$checknum" == "" ]; then
continue
fi
read -p "请再次输入您的登录验证码:" checknum2
if [ "$checknum" != "$checknum2" ]; then
echo "两次验证码不一致!请重新输入您的登录验证码"
continue
else
screen -x -S userbot -p 0 -X stuff "$checknum"
screen -x -S userbot -p 0 -X stuff $'\n'
if [ ! -f "/var/lib/PagerMaid-Modify/pagermaid.session-journal" ]; then
read -p "您是否有二次登录验证码(y或n & 不知道二次登录验证码是什么请回车): " choi
if [ "$choi" == "y" ]; then
break
fi
done
read -p "有没有二次登录验证码? [Y/n]" choi
if [ "$choi" == "y" ] || [ "$choi" == "Y" ]; then
read -p "请输入您的二次登录验证码: " twotimepwd
screen -x -S userbot -p 0 -X stuff "$twotimepwd"
screen -x -S userbot -p 0 -X stuff $'\n'
elif [ "$choi" == "n" ] || [ "$choi" == "" ]; then
echo "登录验证码错误!"
sleep 3
ftime+=1
read_checknum
fi
fi
}
login_screen() {
@ -343,42 +338,58 @@ login_screen(){
sleep 1
screen -x -S userbot -p 0 -X stuff "cd /var/lib/pagermaid && $PYV -m pagermaid"
screen -x -S userbot -p 0 -X stuff $'\n'
while :
do
read -p "请输入您的 Telegram 手机号码: " phonenum
sleep 3
if [ "$(ps -def | grep [p]agermaid | grep -v grep)" == "" ]; then
echo "PagerMaid 运行时发生错误,错误信息:"
cd /var/lib/pagermaid && $PYV -m pagermaid >err.log
cat err.log
screen -S userbot -X quit >>/dev/null 2>&1
exit 1
fi
while :; do
read -p "请输入您的 Telegram 手机号码(带国际区号 如 +8618888888888: " phonenum
if [ "$phonenum" == "" ]; then
continue;
continue
fi
screen -x -S userbot -p 0 -X stuff "$phonenum"
screen -x -S userbot -p 0 -X stuff $'\n'
if [ "$(ps aux|grep [p]agermaid)" == "" ];then
echo "手机号输入错误!请确认您是否带了区号(中国号码为 +86 如 +8613301237756"
if [ "$(ps -def | grep [p]agermaid | grep -v grep)" == "" ]; then
echo "手机号输入错误!请确认您是否带了区号(中国号码为 +86 如 +8618888888888"
screen -x -S userbot -p 0 -X stuff "cd /var/lib/pagermaid && $PYV -m pagermaid"
screen -x -S userbot -p 0 -X stuff $'\n'
continue
fi
read -p "请输入您的登录验证码: " checknum
screen -x -S userbot -p 0 -X stuff "$checknum"
screen -x -S userbot -p 0 -X stuff $'\n'
if [ ! -f "/var/lib/PagerMaid-Modify/pagermaid.session-journal" ]; then
read -p "您是否有二次登录验证码(y或n & 不知道二次登录验证码是什么请回车): " choi
sleep 1
if [ "$(ps -def | grep [p]agermaid | grep -v grep)" == "" ]; then
echo "PagerMaid 运行时发生错误,可能是因为发送验证码失败,请检查您的 API_KEY 和 API_HASH"
exit 1
fi
if [ "$choi" == "y" ]; then
read -p "请输入您的二次登录验证码: " twotimepwd
screen -x -S userbot -p 0 -X stuff "$twotimepwd"
screen -x -S userbot -p 0 -X stuff $'\n'
break
elif [ "$choi" == "n" ] || [ "$choi" == "" ]; then
echo "登录验证码错误!"
sleep 3
ftime+=1
read -p "请输入您的登录验证码: " checknum
if [ "$checknum" == "" ]; then
read_checknum
break
fi
read -p "请再次输入您的登录验证码:" checknum2
if [ "$checknum" != "$checknum2" ]; then
echo "两次验证码不一致!请重新输入您的登录验证码"
read_checknum
break
else
screen -x -S userbot -p 0 -X stuff "$checknum"
screen -x -S userbot -p 0 -X stuff $'\n'
fi
read -p "有没有二次登录验证码? [Y/n]" choi
if [ "$choi" == "y" ] || [ "$choi" == "Y" ]; then
read -p "请输入您的二次登录验证码: " twotimepwd
screen -x -S userbot -p 0 -X stuff "$twotimepwd"
screen -x -S userbot -p 0 -X stuff $'\n'
fi
done
sleep 5