Skip to content

Commit

Permalink
return Rclone job info to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
wy580477 committed Jun 19, 2022
1 parent 421500b commit 1024d68
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions content/aria2/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ UPLOAD_FILE() {
echo
)
if [ -f "${LOCAL_PATH}" ]; then
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${DOWNLOAD_DIR}"'","srcRemote":"'"${TASK_FILE_NAME}"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"${TASK_FILE_NAME}"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file'
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${DOWNLOAD_DIR}"'","srcRemote":"'"${TASK_FILE_NAME}"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"${TASK_FILE_NAME}"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file' | jq .jobid | sed 's/\"//g')"
else
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${LOCAL_PATH}"'","dstFs":"'"${REMOTE_PATH}"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}''
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${LOCAL_PATH}"'","dstFs":"'"${REMOTE_PATH}"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}'' | jq .jobid | sed 's/\"//g')"
fi
RCLONE_EXIT_CODE=$?
if [ ${RCLONE_EXIT_CODE} -eq 0 ]; then
if [ "${JOB_ID}" != "" ]; then
UPLOAD_LOG="$(DATE_TIME) ${INFO} Successfully send job to rclone: ${LOCAL_PATH} -> ${REMOTE_PATH}"
OUTPUT_UPLOAD_LOG
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"jobid":"'"${JOB_ID}"'"}' 'localhost:61802/job/status'
DELETE_EMPTY_DIR
break
else
Expand Down
8 changes: 4 additions & 4 deletions content/gdltorclone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}${BASE_PATH}"
if [ "${UPLOAD_MODE}" = "disable" ]; then
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled"
else
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${DL_PATH}"'","dstFs":"'"${REMOTE_PATH}"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}''
EXIT_CODE=$?
if [ ${EXIT_CODE} -eq 0 ]; then
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${DL_PATH}"'","dstFs":"'"${REMOTE_PATH}"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}'' | jq .jobid | sed 's/\"//g')"
if [ "${JOB_ID}" != "" ]; then
echo "$(DATE_TIME) [INFO] Successfully send job to rclone: $1 -> ${REMOTE_PATH}"
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"jobid":"'"${JOB_ID}"'"}' 'localhost:61802/job/status'
else
echo "$(DATE_TIME) [ERROR] Failed to send job to rclone: $1"
fi
fi

if [[ "${DELETE_EMPTY_DIR}" = "true" ]]; then
find ${DOWNLOAD_DIR} -depth -mindepth 1 -type d -empty -exec rm -vrf {} \; 2>/dev/null
fi
fi
6 changes: 3 additions & 3 deletions content/pyload_to_rclone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}${DEST_PATH_SUFFIX}"
if [ "${UPLOAD_MODE}" = "disable" ]; then
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled"
else
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${FILE_PATH}"'","srcRemote":"'"$2"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"$2"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file'
EXIT_CODE=$?
if [ ${EXIT_CODE} -eq 0 ]; then
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${FILE_PATH}"'","srcRemote":"'"$2"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"$2"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file' | jq .jobid | sed 's/\"//g')"
if [ "${JOB_ID}" != "" ]; then
echo "$(DATE_TIME) [INFO] Successfully send job to rclone: $3 -> ${REMOTE_PATH}"
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"jobid":"'"${JOB_ID}"'"}' 'localhost:61802/job/status'
else
echo "$(DATE_TIME) [ERROR] Failed to send job to rclone: $3"
fi
Expand Down
6 changes: 3 additions & 3 deletions content/pyload_to_rclone_package_extracted.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}"
if [ "${UPLOAD_MODE}" = "disable" ]; then
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled"
else
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"$3"'","dstFs":"'"${REMOTE_PATH}"'/'"$2"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}''
EXIT_CODE=$?
if [ ${EXIT_CODE} -eq 0 ]; then
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"$3"'","dstFs":"'"${REMOTE_PATH}"'/'"$2"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}'' | jq .jobid | sed 's/\"//g')"
if [ "${JOB_ID}" != "" ]; then
echo "$(DATE_TIME) [INFO] Successfully send job to rclone: $3 -> ${REMOTE_PATH}"
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"jobid":"'"${JOB_ID}"'"}' 'localhost:61802/job/status'
else
echo "$(DATE_TIME) [ERROR] Failed to send job to rclone: $3"
fi
Expand Down
12 changes: 6 additions & 6 deletions content/qbittorclone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}${DEST_PATH_SUFFIX}"
if [ "${UPLOAD_MODE}" = "disable" ]; then
echo "[INFO] Auto-upload to Rclone remote disabled"
elif [ -f "$1" ]; then
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${FILE_PATH}"'","srcRemote":"'"${FILE_NAME}"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"${FILE_NAME}"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file'
EXIT_CODE=$?
if [ ${EXIT_CODE} -eq 0 ]; then
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${FILE_PATH}"'","srcRemote":"'"${FILE_NAME}"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"${FILE_NAME}"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file' | jq .jobid | sed 's/\"//g')"
if [ "${JOB_ID}" != "" ]; then
echo "[INFO] Successfully send job to rclone: $1 -> ${REMOTE_PATH}"
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"jobid":"'"${JOB_ID}"'"}' 'localhost:61802/job/status'
else
echo "[ERROR] Failed to send job to rclone: $1"
fi
else
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"$1"'","dstFs":"'"${REMOTE_PATH}"'/'"$2"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}''
EXIT_CODE=$?
if [ ${EXIT_CODE} -eq 0 ]; then
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"$1"'","dstFs":"'"${REMOTE_PATH}"'/'"$2"'","_async":"true"}' 'localhost:61802/sync/'${UPLOAD_MODE}'' | jq .jobid | sed 's/\"//g')"
if [ "${JOB_ID}" != "" ]; then
echo "[INFO] Successfully send job to rclone: $1 -> ${REMOTE_PATH}"
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"jobid":"'"${JOB_ID}"'"}' 'localhost:61802/job/status'
else
echo "[ERROR] Failed to send job to rclone: $1"
fi
Expand Down
6 changes: 3 additions & 3 deletions content/ytdlptorclone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ mv "$1" "${FILEPATH}""${FILENAME}"
if [ "${UPLOAD_MODE}" = "disable" ]; then
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled"
else
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${FILEPATH}"'","srcRemote":"'"${FILENAME}"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"${FILENAME}"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file'
EXIT_CODE=$?
if [ ${EXIT_CODE} -eq 0 ]; then
JOB_ID="$(curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"srcFs":"'"${FILEPATH}"'","srcRemote":"'"${FILENAME}"'","dstFs":"'"${REMOTE_PATH}"'","dstRemote":"'"${FILENAME}"'","_async":"true"}' 'localhost:61802/operations/'${UPLOAD_MODE}'file' | jq .jobid | sed 's/\"//g')"
if [ "${JOB_ID}" != "" ]; then
echo "$(DATE_TIME) [INFO] Successfully send job to rclone: $1 -> ${REMOTE_PATH}"
curl -s -u ${GLOBAL_USER}:${GLOBAL_PASSWORD} -H "Content-Type: application/json" -f -X POST -d '{"jobid":"'"${JOB_ID}"'"}' 'localhost:61802/job/status'
else
echo "$(DATE_TIME) [ERROR] Failed to send job to rclone: $1"
fi
Expand Down

0 comments on commit 1024d68

Please sign in to comment.