forked from peng4740/aria2-cloud189
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-189.sh
54 lines (51 loc) · 1.64 KB
/
upload-189.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
GID="$1";
FileNum="$2";
File="$3";
MinSize="5" #限制最低上传大小,默认5k
MaxSize="157286400" #限制最高文件大小(单位k),默认15G
#RemoteDIR="/RATS/"; #rclone挂载的本地文件夹,最后面保留/
LocalDIR="/root/downloads/"; #Aria2下载目录,最后面保留/
if [[ -z $(echo "$FileNum" |grep -o '[0-9]*' |head -n1) ]]; then FileNum='0'; fi
if [[ "$FileNum" -le '0' ]]; then exit 0; fi
if [[ "$#" != '3' ]]; then exit 0; fi
function LoadFile(){
IFS_BAK=$IFS
IFS=$'\n'
if [[ ! -d "$LocalDIR" ]]; then return; fi
if [[ -e "$File" ]]; then
FileLoad="${File/#$LocalDIR}"
while true
do
if [[ "$FileLoad" == '/' ]]; then return; fi
echo "$FileLoad" |grep -q '/';
if [[ "$?" == "0" ]]; then
FileLoad=$(dirname "$FileLoad");
else
break;
fi;
done;
if [[ "$FileLoad" == "$LocalDIR" ]]; then return; fi
EXEC="$(command -v python3)"
if [[ -z "$EXEC" ]]; then return; fi
Option=" ~/cloud189/main.py upload";
cd "$LocalDIR";
if [[ -e "$FileLoad" ]]; then
ItemSize=$(du -s "$FileLoad" |cut -f1 |grep -o '[0-9]*' |head -n1)
if [[ -z "$ItemSize" ]]; then return; fi
if [[ "$ItemSize" -le "$MinSize" ]]; then
echo -ne "\033[33m$FileLoad \033[0mtoo small to spik.\n";
return;
fi
if [[ "$ItemSize" -ge "$MaxSize" ]]; then
echo -ne "\033[33m$FileLoad \033[0mtoo large to spik.\n";
return;
fi
#eval "${EXEC}${Option}" \'"${FileLoad}"\' "${RemoteDIR}";
eval "${EXEC}${Option}" \'"${FileLoad}"\';
rm -rf "${FileLoad}"
fi
fi
IFS=$IFS_BAK
}
LoadFile;