From 768cffff9978c521c3742d6633e7f4c1dfbbde19 Mon Sep 17 00:00:00 2001 From: shenmo Date: Thu, 13 Jul 2023 14:43:01 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BB=A4=E4=BA=BA=E7=AA=92=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E7=BB=9F=E8=AE=A1=E4=B8=8B=E8=BD=BD=E9=87=8F?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenmo --- shell/mail-get-downloadsh | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 shell/mail-get-downloadsh diff --git a/shell/mail-get-downloadsh b/shell/mail-get-downloadsh new file mode 100644 index 0000000..a916ec7 --- /dev/null +++ b/shell/mail-get-downloadsh @@ -0,0 +1,63 @@ +#/bin/bash +DEPEND=`dpkg -l | grep dos2unix` +if [ "$DEPEND" = "" ] ; then +echo "未安装依赖:dos2unix 本脚本退出" +exit 0 +fi + + +EMAIL_ADDRESS_AND_PASSWD=$1 + + +REPOPATH="/home/ftp/spark-store/" #设置软件源目录 +if [ "`curl pop3s://pop.163.com/ --user $EMAIL_ADDRESS_AND_PASSWD -s | grep 1`" = "" ];then +echo "无邮件需要处理,完成" +exit +fi + + +DOWNLOAD_NUMBERS=`curl pop3s://pop.163.com/ --user $EMAIL_ADDRESS_AND_PASSWD -s | wc -l` +echo "有$DOWNLOAD_NUMBERS封邮件等待处理!" + +i=1 +until [ "$i" -gt "$DOWNLOAD_NUMBERS" ];do + +curl pop3s://pop.163.com/1 --user $EMAIL_ADDRESS_AND_PASSWD -s > ./tmp.log +dos2unix ./tmp.log >/dev/null 2>&1 +if [ "`cat ./tmp.log | grep check="i love amber forever" `" = "" ];then +curl --request DELE pop3s://pop.163.com/1 --user $EMAIL_ADDRESS_AND_PASSWD --list-only +echo "邮件无验证信息,可能为垃圾邮件,丢弃" + + else + echo "开始检验指令" + COMMAND="`sed -n '/command:/p' ./tmp.log`" + case "$COMMAND" in + command:download_count) + APP_LOCATION="`cat ./tmp.log | grep APP_LOCATION=`" + APP_LOCATION="`echo ${APP_LOCATION} | sed {s/APP_LOCATION=//}`" + ALREADY_DOWNLOADED_NUM=`cat $REPOPATH/$APP_LOCATION/download-times.txt` + let ALREADY_DOWNLOADED_NUM=$ALREADY_DOWNLOADED_NUM+1 + echo ${ALREADY_DOWNLOADED_NUM} > $REPOPATH/$APP_LOCATION/download-times.txt + echo "$REPOPATH/$APP_LOCATION 的下载量现在为 ${ALREADY_DOWNLOADED_NUM}" + ;; + *) + echo "未定义的行为,抛弃" + ;; + + esac + curl --request DELE pop3s://pop.163.com/1 --user $EMAIL_ADDRESS_AND_PASSWD --list-only +rm ./tmp.log + +fi + + + +let i=$i+1 +done + + +if [ "`curl pop3s://pop.163.com/ --user $EMAIL_ADDRESS_AND_PASSWD -s | grep 1`" != "" ];then +$0 +echo "处理结束,退出" +exit +fi -- Gitee