💩 一键脚本修锅 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

@ -5,7 +5,7 @@ if [[ $EUID -ne 0 ]]; then
exit 1 exit 1
fi fi
check_sys(){ check_sys() {
if [[ -f /etc/redhat-release ]]; then if [[ -f /etc/redhat-release ]]; then
release="centos" release="centos"
elif cat /etc/issue | grep -q -E -i "debian"; then elif cat /etc/issue | grep -q -E -i "debian"; then
@ -33,226 +33,222 @@ welcome() {
sleep 5 sleep 5
} }
yum_update(){ yum_update() {
echo "正在优化 yum . . ." echo "正在优化 yum . . ."
yum install yum-utils epel-release -y >> /dev/null 2>&1 yum install yum-utils epel-release -y >>/dev/null 2>&1
} }
yum_git_check() { yum_git_check() {
echo "正在检查 Git 安装情况 . . ." echo "正在检查 Git 安装情况 . . ."
if command -v git >> /dev/null 2>&1; if command -v git >>/dev/null 2>&1; then
then
echo "Git 似乎存在,安装过程继续 . . ." echo "Git 似乎存在,安装过程继续 . . ."
else else
echo "Git 未安装在此系统上,正在进行安装" echo "Git 未安装在此系统上,正在进行安装"
yum install git -y >> /dev/null 2>&1 yum install git -y >>/dev/null 2>&1
fi fi
} }
yum_python_check() { yum_python_check() {
echo "正在检查 python 安装情况 . . ." echo "正在检查 python 安装情况 . . ."
if command -v python3 >> /dev/null 2>&1;then if command -v python3 >>/dev/null 2>&1; then
U_V1=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'` 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_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}')
if [ $U_V1 -gt 3 ];then if [ $U_V1 -gt 3 ]; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
elif [ $U_V2 -ge 6 ];then elif [ $U_V2 -ge 6 ]; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
PYV=$U_V1.$U_V2 PYV=$U_V1.$U_V2
PYV=`which python$PYV` PYV=$(which python$PYV)
else else
if command -v python3.6 >> /dev/null 2>&1;then if command -v python3.6 >>/dev/null 2>&1; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
PYV=`which python3.6` PYV=$(which python3.6)
else else
echo "Python3.6 未安装在此系统上,正在进行安装" echo "Python3.6 未安装在此系统上,正在进行安装"
yum install python3 -y >> /dev/null 2>&1 yum install python3 -y >>/dev/null 2>&1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >> /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
fi fi
else else
echo "Python3.6 未安装在此系统上,正在进行安装" echo "Python3.6 未安装在此系统上,正在进行安装"
yum install python3 -y >> /dev/null 2>&1 yum install python3 -y >>/dev/null 2>&1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >> /dev/null 2>&1 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >>/dev/null 2>&1
fi fi
if command -v pip3 >> /dev/null 2>&1;then if command -v pip3 >>/dev/null 2>&1; then
echo 'pip 存在 . . .' echo 'pip 存在 . . .'
else else
echo "pip3 未安装在此系统上,正在进行安装" echo "pip3 未安装在此系统上,正在进行安装"
yum install -y python3-pip >> /dev/null 2>&1 yum install -y python3-pip >>/dev/null 2>&1
fi fi
} }
yum_screen_check() { yum_screen_check() {
echo "正在检查 Screen 安装情况 . . ." echo "正在检查 Screen 安装情况 . . ."
if command -v screen >> /dev/null 2>&1; if command -v screen >>/dev/null 2>&1; then
then
echo "Screen 似乎存在, 安装过程继续 . . ." echo "Screen 似乎存在, 安装过程继续 . . ."
else else
echo "Screen 未安装在此系统上,正在进行安装" echo "Screen 未安装在此系统上,正在进行安装"
yum install screen -y >> /dev/null 2>&1 yum install screen -y >>/dev/null 2>&1
fi fi
} }
yum_require_install(){ yum_require_install() {
echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ." echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ."
yum install python-devel python3-devel zbar zbar-devel ImageMagick wget -y >> /dev/null 2>&1 yum install python-devel python3-devel zbar zbar-devel ImageMagick wget -y >>/dev/null 2>&1
wget -T 2 -O /etc/yum.repos.d/konimex-neofetch-epel-7.repo https://copr.fedorainfracloud.org/coprs/konimex/neofetch/repo/epel-7/konimex-neofetch-epel-7.repo >> /dev/null 2>&1 wget -T 2 -O /etc/yum.repos.d/konimex-neofetch-epel-7.repo https://copr.fedorainfracloud.org/coprs/konimex/neofetch/repo/epel-7/konimex-neofetch-epel-7.repo >>/dev/null 2>&1
yum groupinstall "Development Tools" -y >> /dev/null 2>&1 yum groupinstall "Development Tools" -y >>/dev/null 2>&1
yum-config-manager --add-repo https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/ >> /dev/null 2>&1 yum-config-manager --add-repo https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/ >>/dev/null 2>&1
sudo rpm --import https://build.opensuse.org/projects/home:Alexander_Pozdnyakov/public_key >> /dev/null 2>&1 sudo rpm --import https://build.opensuse.org/projects/home:Alexander_Pozdnyakov/public_key >>/dev/null 2>&1
yum list updates >> /dev/null 2>&1 yum list updates >>/dev/null 2>&1
yum install neofetch figlet tesseract tesseract-langpack-chi-sim tesseract-langpack-eng -y >> /dev/null 2>&1 yum install neofetch figlet tesseract tesseract-langpack-chi-sim tesseract-langpack-eng -y >>/dev/null 2>&1
} }
apt_update(){ apt_update() {
echo "正在优化 apt-get . . ." echo "正在优化 apt-get . . ."
apt-get install sudo -y >> /dev/null 2>&1 apt-get install sudo -y >>/dev/null 2>&1
apt-get update >> /dev/null 2>&1 apt-get update >>/dev/null 2>&1
} }
apt_git_check() { apt_git_check() {
echo "正在检查 Git 安装情况 . . ." echo "正在检查 Git 安装情况 . . ."
if command -v git >> /dev/null 2>&1; if command -v git >>/dev/null 2>&1; then
then
echo "Git 似乎存在, 安装过程继续 . . ." echo "Git 似乎存在, 安装过程继续 . . ."
else else
echo "Git 未安装在此系统上,正在进行安装" echo "Git 未安装在此系统上,正在进行安装"
apt-get install git -y >> /dev/null 2>&1 apt-get install git -y >>/dev/null 2>&1
fi fi
} }
apt_python_check() { apt_python_check() {
echo "正在检查 python 安装情况 . . ." echo "正在检查 python 安装情况 . . ."
if command -v python3 >> /dev/null 2>&1;then if command -v python3 >>/dev/null 2>&1; then
U_V1=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'` 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_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}')
if [ $U_V1 -gt 3 ];then if [ $U_V1 -gt 3 ]; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
elif [ $U_V2 -ge 6 ];then elif [ $U_V2 -ge 6 ]; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
PYV=$U_V1.$U_V2 PYV=$U_V1.$U_V2
PYV=`which python$PYV` PYV=$(which python$PYV)
else else
if command -v python3.6 >> /dev/null 2>&1;then if command -v python3.6 >>/dev/null 2>&1; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
PYV=`which python3.6` PYV=$(which python3.6)
else else
echo "Python3.6 未安装在此系统上,正在进行安装" echo "Python3.6 未安装在此系统上,正在进行安装"
add-apt-repository ppa:deadsnakes/ppa -y add-apt-repository ppa:deadsnakes/ppa -y
apt-get update >> /dev/null 2>&1 apt-get update >>/dev/null 2>&1
apt-get install python3.6 -y >> /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 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
fi fi
else else
echo "Python3.6 未安装在此系统上,正在进行安装" echo "Python3.6 未安装在此系统上,正在进行安装"
add-apt-repository ppa:deadsnakes/ppa -y add-apt-repository ppa:deadsnakes/ppa -y
apt-get update >> /dev/null 2>&1 apt-get update >>/dev/null 2>&1
apt-get install python3.6 -y >> /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 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 >>/dev/null 2>&1
fi fi
if command -v pip3 >> /dev/null 2>&1;then if command -v pip3 >>/dev/null 2>&1; then
echo 'pip 存在 . . .' echo 'pip 存在 . . .'
else else
echo "pip3 未安装在此系统上,正在进行安装" echo "pip3 未安装在此系统上,正在进行安装"
apt-get install -y python3-pip >> /dev/null 2>&1 apt-get install -y python3-pip >>/dev/null 2>&1
fi fi
} }
debian_python_check() { debian_python_check() {
echo "正在检查 python 安装情况 . . ." echo "正在检查 python 安装情况 . . ."
if command -v python3 >> /dev/null 2>&1;then if command -v python3 >>/dev/null 2>&1; then
U_V1=`python3 -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'` 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_V2=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $2}')
if [ $U_V1 -gt 3 ];then if [ $U_V1 -gt 3 ]; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
elif [ $U_V2 -ge 6 ];then elif [ $U_V2 -ge 6 ]; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
PYV=$U_V1.$U_V2 PYV=$U_V1.$U_V2
PYV=`which python$PYV` PYV=$(which python$PYV)
else else
if command -v python3.6 >> /dev/null 2>&1;then if command -v python3.6 >>/dev/null 2>&1; then
echo 'Python 3.6+ 存在 . . .' echo 'Python 3.6+ 存在 . . .'
PYV=`which python3.6` PYV=$(which python3.6)
else else
echo "Python3.6 未安装在此系统上,正在进行安装" echo "Python3.6 未安装在此系统上,正在进行安装"
apt-get update -y >> /dev/null 2>&1 apt-get update -y >>/dev/null 2>&1
apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev >> /dev/null 2>&1 apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev >>/dev/null 2>&1
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz >> /dev/null 2>&1 wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz >>/dev/null 2>&1
tar -xvf Python-3.6.5.tgz >> /dev/null 2>&1 tar -xvf Python-3.6.5.tgz >>/dev/null 2>&1
chmod -R +x Python-3.6.5 >> /dev/null 2>&1 chmod -R +x Python-3.6.5 >>/dev/null 2>&1
cd Python-3.6.5 >> /dev/null 2>&1 cd Python-3.6.5 >>/dev/null 2>&1
./configure >> /dev/null 2>&1 ./configure >>/dev/null 2>&1
make&& make install >> /dev/null 2>&1 make && make install >>/dev/null 2>&1
cd .. >> /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 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 update-alternatives --install $PYP python3 $PYV 1 >>/dev/null 2>&1
fi fi
fi fi
else else
echo "Python3.6 未安装在此系统上,正在进行安装" echo "Python3.6 未安装在此系统上,正在进行安装"
apt-get update -y >> /dev/null 2>&1 apt-get update -y >>/dev/null 2>&1
apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev >> /dev/null 2>&1 apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev >>/dev/null 2>&1
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz >> /dev/null 2>&1 wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz >>/dev/null 2>&1
tar -xvf Python-3.6.5.tgz >> /dev/null 2>&1 tar -xvf Python-3.6.5.tgz >>/dev/null 2>&1
chmod -R +x Python-3.6.5 >> /dev/null 2>&1 chmod -R +x Python-3.6.5 >>/dev/null 2>&1
cd Python-3.6.5 >> /dev/null 2>&1 cd Python-3.6.5 >>/dev/null 2>&1
./configure >> /dev/null 2>&1 ./configure >>/dev/null 2>&1
make&& make install >> /dev/null 2>&1 make && make install >>/dev/null 2>&1
cd .. >> /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 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 update-alternatives --install $PYP python3 $PYV 1 >>/dev/null 2>&1
fi fi
echo "正在检查 pip3 安装情况 . . ." echo "正在检查 pip3 安装情况 . . ."
if command -v pip3 >> /dev/null 2>&1;then if command -v pip3 >>/dev/null 2>&1; then
echo 'pip 存在 . . .' echo 'pip 存在 . . .'
else else
echo "pip3 未安装在此系统上,正在进行安装" echo "pip3 未安装在此系统上,正在进行安装"
apt-get install -y python3-pip >> /dev/null 2>&1 apt-get install -y python3-pip >>/dev/null 2>&1
fi fi
} }
apt_screen_check() { apt_screen_check() {
echo "正在检查 Screen 安装情况 . . ." echo "正在检查 Screen 安装情况 . . ."
if command -v screen >> /dev/null 2>&1; if command -v screen >>/dev/null 2>&1; then
then
echo "Screen 似乎存在, 安装过程继续 . . ." echo "Screen 似乎存在, 安装过程继续 . . ."
else else
echo "Screen 未安装在此系统上,正在进行安装" echo "Screen 未安装在此系统上,正在进行安装"
apt-get install screen -y >> /dev/null 2>&1 apt-get install screen -y >>/dev/null 2>&1
fi fi
} }
apt_require_install(){ apt_require_install() {
echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ." echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ."
apt-get install python3.6-dev python3-dev imagemagick software-properties-common tesseract-ocr tesseract-ocr-chi-sim libzbar-dev -y >> /dev/null 2>&1 apt-get install python3.6-dev python3-dev imagemagick software-properties-common tesseract-ocr tesseract-ocr-chi-sim libzbar-dev -y >>/dev/null 2>&1
add-apt-repository ppa:dawidd0811/neofetch -y add-apt-repository ppa:dawidd0811/neofetch -y
apt-get install neofetch -y >> /dev/null 2>&1 apt-get install neofetch -y >>/dev/null 2>&1
} }
debian_require_install(){ debian_require_install() {
echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ." echo "正在安装系统所需依赖,可能需要几分钟的时间 . . ."
apt-get install imagemagick software-properties-common tesseract-ocr tesseract-ocr-chi-sim libzbar-dev neofetch -y >> /dev/null 2>&1 apt-get install imagemagick software-properties-common tesseract-ocr tesseract-ocr-chi-sim libzbar-dev neofetch -y >>/dev/null 2>&1
} }
download_repo() { download_repo() {
echo "下载 repository 中 . . ." echo "下载 repository 中 . . ."
rm -rf /var/lib/pagermaid >> /dev/null 2>&1 rm -rf /var/lib/pagermaid >>/dev/null 2>&1
git clone https://github.com/xtaodada/PagerMaid-Modify.git /var/lib/pagermaid >> /dev/null 2>&1 git clone https://github.com/xtaodada/PagerMaid-Modify.git /var/lib/pagermaid >>/dev/null 2>&1
cd /var/lib/pagermaid >> /dev/null 2>&1 cd /var/lib/pagermaid >>/dev/null 2>&1
echo "Hello World!">/var/lib/pagermaid/public.lock echo "Hello World!" >/var/lib/pagermaid/public.lock
} }
pypi_install(){ pypi_install() {
echo "下载安装 pypi 依赖中 . . ." echo "下载安装 pypi 依赖中 . . ."
$PYV -m pip install --upgrade pip >> /dev/null 2>&1 $PYV -m pip install --upgrade pip >>/dev/null 2>&1
$PYV -m pip install -r requirements.txt >> /dev/null 2>&1 $PYV -m pip install -r requirements.txt >>/dev/null 2>&1
sudo -H $PYV -m pip install --ignore-installed PyYAML >> /dev/null 2>&1 sudo -H $PYV -m pip install --ignore-installed PyYAML >>/dev/null 2>&1
} }
configure() { configure() {
@ -268,24 +264,21 @@ configure() {
sed -i "s/HASH_HERE/$api_hash/" $config_file sed -i "s/HASH_HERE/$api_hash/" $config_file
printf "请输入应用程序语言默认zh-cn" printf "请输入应用程序语言默认zh-cn"
read -r application_language <&1 read -r application_language <&1
if [ -z "$application_language" ] if [ -z "$application_language" ]; then
then
echo "语言设置为 简体中文" echo "语言设置为 简体中文"
else else
sed -i "s/zh-cn/$application_language/" $config_file sed -i "s/zh-cn/$application_language/" $config_file
fi fi
printf "请输入应用程序地区默认China" printf "请输入应用程序地区默认China"
read -r application_region <&1 read -r application_region <&1
if [ -z "$application_region" ] if [ -z "$application_region" ]; then
then
echo "地区设置为 中国" echo "地区设置为 中国"
else else
sed -i "s/China/$application_region/" $config_file sed -i "s/China/$application_region/" $config_file
fi fi
printf "请输入 Google TTS 语言默认zh-CN" printf "请输入 Google TTS 语言默认zh-CN"
read -r application_tts <&1 read -r application_tts <&1
if [ -z "$application_tts" ] if [ -z "$application_tts" ]; then
then
echo "tts发音语言设置为 简体中文" echo "tts发音语言设置为 简体中文"
else else
sed -i "s/zh-CN/$application_tts/" $config_file sed -i "s/zh-CN/$application_tts/" $config_file
@ -293,18 +286,17 @@ configure() {
printf "启用日志记录? [Y/n]" printf "启用日志记录? [Y/n]"
read -r logging_confirmation <&1 read -r logging_confirmation <&1
case $logging_confirmation in case $logging_confirmation in
[yY][eE][sS]|[yY]) [yY][eE][sS] | [yY])
printf "请输入您的日志记录群组/频道的 ChatID (如果要发送给 原 PagerMaid 作者 请按Enter" printf "请输入您的日志记录群组/频道的 ChatID (如果要发送给 原 PagerMaid 作者 请按Enter"
read -r log_chatid <&1 read -r log_chatid <&1
if [ -z "$log_chatid" ] if [ -z "$log_chatid" ]; then
then
echo "LOG 将发送到 原 PagerMaid 作者." echo "LOG 将发送到 原 PagerMaid 作者."
else else
sed -i "s/503691334/$log_chatid/" $config_file sed -i "s/503691334/$log_chatid/" $config_file
fi fi
sed -i "s/log: False/log: True/" $config_file sed -i "s/log: False/log: True/" $config_file
;; ;;
[nN][oO]|[nN]) [nN][oO] | [nN])
echo "安装过程继续 . . ." echo "安装过程继续 . . ."
;; ;;
*) *)
@ -314,78 +306,97 @@ configure() {
esac esac
} }
read_checknum(){ read_checknum() {
if [ "$ftime" == "111" ]; then while :; do
echo "失败次数达到上限!" && exit 1
fi
read -p "请输入您的登录验证码: " checknum 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 "$checknum"
screen -x -S userbot -p 0 -X stuff $'\n' screen -x -S userbot -p 0 -X stuff $'\n'
if [ ! -f "/var/lib/PagerMaid-Modify/pagermaid.session-journal" ]; then break
read -p "您是否有二次登录验证码(y或n & 不知道二次登录验证码是什么请回车): " choi fi
done
if [ "$choi" == "y" ]; then read -p "有没有二次登录验证码? [Y/n]" choi
if [ "$choi" == "y" ] || [ "$choi" == "Y" ]; then
read -p "请输入您的二次登录验证码: " twotimepwd read -p "请输入您的二次登录验证码: " twotimepwd
screen -x -S userbot -p 0 -X stuff "$twotimepwd" screen -x -S userbot -p 0 -X stuff "$twotimepwd"
screen -x -S userbot -p 0 -X stuff $'\n' screen -x -S userbot -p 0 -X stuff $'\n'
elif [ "$choi" == "n" ] || [ "$choi" == "" ]; then
echo "登录验证码错误!"
sleep 3
ftime+=1
read_checknum
fi
fi fi
} }
login_screen(){ login_screen() {
screen -S userbot -X quit >> /dev/null 2>&1 screen -S userbot -X quit >>/dev/null 2>&1
screen -dmS userbot screen -dmS userbot
sleep 1 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 "cd /var/lib/pagermaid && $PYV -m pagermaid"
screen -x -S userbot -p 0 -X stuff $'\n' screen -x -S userbot -p 0 -X stuff $'\n'
while : sleep 3
do if [ "$(ps -def | grep [p]agermaid | grep -v grep)" == "" ]; then
read -p "请输入您的 Telegram 手机号码: " phonenum 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 if [ "$phonenum" == "" ]; then
continue; continue
fi fi
screen -x -S userbot -p 0 -X stuff "$phonenum" screen -x -S userbot -p 0 -X stuff "$phonenum"
screen -x -S userbot -p 0 -X stuff $'\n' screen -x -S userbot -p 0 -X stuff $'\n'
if [ "$(ps aux|grep [p]agermaid)" == "" ];then if [ "$(ps -def | grep [p]agermaid | grep -v grep)" == "" ]; then
echo "手机号输入错误!请确认您是否带了区号(中国号码为 +86 如 +8613301237756" 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 "cd /var/lib/pagermaid && $PYV -m pagermaid"
screen -x -S userbot -p 0 -X stuff $'\n' screen -x -S userbot -p 0 -X stuff $'\n'
continue continue
fi fi
read -p "请输入您的登录验证码: " checknum sleep 1
screen -x -S userbot -p 0 -X stuff "$checknum" if [ "$(ps -def | grep [p]agermaid | grep -v grep)" == "" ]; then
screen -x -S userbot -p 0 -X stuff $'\n' echo "PagerMaid 运行时发生错误,可能是因为发送验证码失败,请检查您的 API_KEY 和 API_HASH"
if [ ! -f "/var/lib/PagerMaid-Modify/pagermaid.session-journal" ]; then exit 1
read -p "您是否有二次登录验证码(y或n & 不知道二次登录验证码是什么请回车): " choi fi
if [ "$choi" == "y" ]; then read -p "请输入您的登录验证码: " checknum
read -p "请输入您的二次登录验证码: " twotimepwd if [ "$checknum" == "" ]; then
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_checknum read_checknum
break break
fi 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 fi
done done
sleep 5 sleep 5
screen -S userbot -X quit >> /dev/null 2>&1 screen -S userbot -X quit >>/dev/null 2>&1
} }
systemctl_reload(){ systemctl_reload() {
echo "正在写入系统进程守护 . . ." echo "正在写入系统进程守护 . . ."
echo "[Unit] echo "[Unit]
Description=PagerMaid-Modify telegram utility daemon Description=PagerMaid-Modify telegram utility daemon
@ -397,11 +408,11 @@ systemctl_reload(){
WorkingDirectory=/var/lib/pagermaid WorkingDirectory=/var/lib/pagermaid
ExecStart=$PYV -m pagermaid ExecStart=$PYV -m pagermaid
Restart=always Restart=always
">/etc/systemd/system/pagermaid.service " >/etc/systemd/system/pagermaid.service
chmod 755 pagermaid.service >> /dev/null 2>&1 chmod 755 pagermaid.service >>/dev/null 2>&1
systemctl daemon-reload >> /dev/null 2>&1 systemctl daemon-reload >>/dev/null 2>&1
systemctl start pagermaid >> /dev/null 2>&1 systemctl start pagermaid >>/dev/null 2>&1
systemctl enable pagermaid >> /dev/null 2>&1 systemctl enable pagermaid >>/dev/null 2>&1
} }
start_installation() { start_installation() {
@ -458,29 +469,29 @@ cleanup() {
echo "目录不存在不需要卸载。" echo "目录不存在不需要卸载。"
else else
echo "正在关闭 PagerMaid . . ." echo "正在关闭 PagerMaid . . ."
systemctl disable pagermaid >> /dev/null 2>&1 systemctl disable pagermaid >>/dev/null 2>&1
systemctl stop pagermaid >> /dev/null 2>&1 systemctl stop pagermaid >>/dev/null 2>&1
echo "正在删除 PagerMaid 文件 . . ." echo "正在删除 PagerMaid 文件 . . ."
rm -rf /etc/systemd/system/pagermaid.service >> /dev/null 2>&1 rm -rf /etc/systemd/system/pagermaid.service >>/dev/null 2>&1
rm -rf /var/lib/pagermaid >> /dev/null 2>&1 rm -rf /var/lib/pagermaid >>/dev/null 2>&1
echo "卸载完成 . . ." echo "卸载完成 . . ."
fi fi
} }
reinstall(){ reinstall() {
cleanup cleanup
start_installation start_installation
} }
cleansession(){ cleansession() {
if [ ! -x "/var/lib/pagermaid" ]; then if [ ! -x "/var/lib/pagermaid" ]; then
echo "目录不存在请重新安装 PagerMaid。" echo "目录不存在请重新安装 PagerMaid。"
exit 1 exit 1
fi fi
echo "正在关闭 PagerMaid . . ." echo "正在关闭 PagerMaid . . ."
systemctl stop pagermaid >> /dev/null 2>&1 systemctl stop pagermaid >>/dev/null 2>&1
echo "正在删除账户授权文件 . . ." echo "正在删除账户授权文件 . . ."
rm -rf /var/lib/pagermaid/pagermaid.session >> /dev/null 2>&1 rm -rf /var/lib/pagermaid/pagermaid.session >>/dev/null 2>&1
echo "请进行重新登陆. . ." echo "请进行重新登陆. . ."
if [ "$release" = "centos" ]; then if [ "$release" = "centos" ]; then
yum_python_check yum_python_check
@ -495,37 +506,37 @@ cleansession(){
echo "目前暂时不支持此系统。" echo "目前暂时不支持此系统。"
fi fi
login_screen login_screen
systemctl start pagermaid >> /dev/null 2>&1 systemctl start pagermaid >>/dev/null 2>&1
} }
stop_pager(){ stop_pager() {
echo "" echo ""
echo "正在关闭 PagerMaid . . ." echo "正在关闭 PagerMaid . . ."
systemctl stop pagermaid >> /dev/null 2>&1 systemctl stop pagermaid >>/dev/null 2>&1
echo "" echo ""
sleep 3 sleep 3
shon_online shon_online
} }
start_pager(){ start_pager() {
echo "" echo ""
echo "正在启动 PagerMaid . . ." echo "正在启动 PagerMaid . . ."
systemctl start pagermaid >> /dev/null 2>&1 systemctl start pagermaid >>/dev/null 2>&1
echo "" echo ""
sleep 3 sleep 3
shon_online shon_online
} }
restart_pager(){ restart_pager() {
echo "" echo ""
echo "正在重新启动 PagerMaid . . ." echo "正在重新启动 PagerMaid . . ."
systemctl restart pagermaid >> /dev/null 2>&1 systemctl restart pagermaid >>/dev/null 2>&1
echo "" echo ""
sleep 3 sleep 3
shon_online shon_online
} }
install_require(){ install_require() {
if [ "$release" = "centos" ]; then if [ "$release" = "centos" ]; then
echo "系统检测通过。" echo "系统检测通过。"
yum_update yum_update
@ -563,23 +574,23 @@ install_require(){
exit 1 exit 1
} }
shon_online(){ shon_online() {
echo "请选择您需要进行的操作:" echo "请选择您需要进行的操作:"
echo " 1) 安装 PagerMaid" echo " 1) 安装 PagerMaid"
echo " 2) 卸载 PagerMaid" echo " 2) 卸载 PagerMaid"
echo " 3) 重新安装 PagerMaid" echo " 3) 重新安装 PagerMaid"
echo " 4) 重新登陆 PagerMaid" echo " 4) 重新登陆 PagerMaid"
echo " 5) 关闭 PagerMaid" echo " 5) 关闭 PagerMaid"
echo " 6) 启动 PagerMaid" echo " 6) 启动 PagerMaid"
echo " 7) 重新启动 PagerMaid" echo " 7) 重新启动 PagerMaid"
echo " 8) 重新安装 PagerMaid 依赖" echo " 8) 重新安装 PagerMaid 依赖"
echo " 9) 退出脚本" echo " 9) 退出脚本"
echo "" echo ""
echo " Version0.1.3" echo " Version0.1.3"
echo "" echo ""
echo -n "请输入编号: " echo -n "请输入编号: "
read N read N
case $N in case $N in
1) start_installation ;; 1) start_installation ;;
2) cleanup ;; 2) cleanup ;;
3) reinstall ;; 3) reinstall ;;
@ -590,7 +601,7 @@ case $N in
8) install_require ;; 8) install_require ;;
9) exit ;; 9) exit ;;
*) echo "Wrong input!" ;; *) echo "Wrong input!" ;;
esac esac
} }
check_sys check_sys