Created
January 11, 2018 17:55
-
-
Save KireinaHoro/12fc8234d848da6c0915ce4ddb948300 to your computer and use it in GitHub Desktop.
mvcompleted.sh to pair with aria2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # $1 is gid. | |
| # $2 is the number of files. | |
| # $3 is the path of the first file. | |
| DOWNLOAD=/home/jsteward/aria2 | |
| #COMPLETE=/home/jsteward/gcscache | |
| LOG=/home/jsteward/aria2/mvcompleted.log | |
| SRC=$3 | |
| if [ "$2" == "0" ]; then | |
| echo `date` "INFO no file to move for" "$1". >> "$LOG" | |
| exit 0 | |
| fi | |
| while true; do | |
| DIR=`dirname "$SRC"` | |
| if [ "$DIR" == "$DOWNLOAD" ]; then | |
| # mv --backup=t "$SRC" "$COMPLETE" >> "$LOG" 2>&1 | |
| rclone copyto "$SRC" "gdrive:archive/Uncategorized/${SRC##*/}" >> "$LOG" 2>&1 || exit 1 | |
| echo `date` "INFO " "$3" moved as gdrive:archive/Uncategorized/${SRC##*/}. >> "$LOG" | |
| # [[ -d "$SRC" ]] && rmdir "$SRC" >> "$LOG" 2>&1 | |
| rm -rf "$SRC" >> "$LOG" 2>&1 | |
| exit 0 | |
| elif [ "$DIR" == "/" -o "$DIR" == "." ]; then | |
| echo `date` "ERROR " "$3" not under "$DOWNLOAD". >> "$LOG" | |
| exit 1 | |
| else | |
| SRC=$DIR | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment