-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
235 additions
and
220 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,40 @@ | ||
#!/bin/bash | ||
|
||
DATE_TIME() { | ||
date +"%m/%d %H:%M:%S" | ||
# | ||
# Created by wy580477 for customized container <https://github.com/wy580477> | ||
# | ||
|
||
LOCAL_PATH="$1" | ||
source /workdir/script_core.sh | ||
|
||
DEFINITION_PATH() { | ||
UPLOAD_MODE="$(grep ^gallery-dl-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DOWNLOAD_DIR="$(jq '."base-directory"' /mnt/data/config/gallery-dl.conf | sed 's/\"//g;s/\r$//')" | ||
GDL_DRIVE_DIR="$(grep ^gdl-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
BASE_PATH="${LOCAL_PATH#"${DOWNLOAD_DIR%/}"}" | ||
if [[ "${GDL_DRIVE_DIR}" =~ :/ ]]; then | ||
REMOTE_PATH="${GDL_DRIVE_DIR}${BASE_PATH}" | ||
else | ||
if [ "${GDL_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/gallery-dl | ||
else | ||
DRIVE_DIR=${GDL_DRIVE_DIR} | ||
fi | ||
REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}${BASE_PATH}" | ||
fi | ||
} | ||
|
||
UPLOAD_MODE="$(grep ^gallery-dl-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DELETE_EMPTY_DIR="$(grep ^delete-empty-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DRIVE_NAME="$(grep ^drive-name /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DOWNLOAD_DIR="$(jq '."base-directory"' /mnt/data/config/gallery-dl.conf | sed 's/\"//g;s/\r$//')" | ||
|
||
DRIVE_NAME_AUTO="$(sed -n '1p' /mnt/data/config/rclone.conf | sed "s/.*\[//g;s/\].*//g;s/\r$//")" | ||
if [ "${DRIVE_NAME}" = "auto" ]; then | ||
DRIVENAME=${DRIVE_NAME_AUTO} | ||
else | ||
DRIVENAME=${DRIVE_NAME} | ||
fi | ||
|
||
GLOBAL_DRIVE_DIR="$(grep ^drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
GDL_DRIVE_DIR="$(grep ^gdl-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
|
||
if [ "${GDL_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/gallery-dl | ||
else | ||
DRIVE_DIR=${GDL_DRIVE_DIR} | ||
fi | ||
|
||
DL_PATH="$1" | ||
BASE_PATH="${DL_PATH#"${DOWNLOAD_DIR%/}"}" | ||
REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}${BASE_PATH}" | ||
|
||
if [ "${UPLOAD_MODE}" = "disable" ]; then | ||
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled" | ||
else | ||
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' | ||
UPLOAD_TASK() { | ||
if [ "${UPLOAD_MODE}" = "disable" ]; then | ||
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled" | ||
else | ||
echo "$(DATE_TIME) [ERROR] Failed to send job to rclone: $1" | ||
UPLOAD_FOLDER | ||
fi | ||
fi | ||
if [ "${JOB_ID}" = "" ]; then | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [[ "${DELETE_EMPTY_DIR}" = "true" ]]; then | ||
find ${DOWNLOAD_DIR} -depth -mindepth 1 -type d -empty -exec rm -vrf {} \; 2>/dev/null | ||
fi | ||
GET_PATH | ||
DEFINITION_PATH | ||
UPLOAD_TASK | ||
CLEAN_EMPTY_DIR |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,39 @@ | ||
#!/bin/sh | ||
|
||
DATE_TIME() { | ||
date +"%m/%d %H:%M:%S" | ||
#!/bin/bash | ||
# | ||
# Created by wy580477 for customized container <https://github.com/wy580477> | ||
# | ||
|
||
LOCAL_PATH="$3" | ||
FILE_NAME="$2" | ||
source /workdir/script_core.sh | ||
|
||
DEFINITION_PATH() { | ||
UPLOAD_MODE="$(grep ^pyload-download-finished-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DOWNLOAD_DIR="$(grep ^'.*folder storage_folder' /workdir/.pyload/settings/pyload.cfg | cut -d= -f2- | sed "s/\r$//")" | ||
PYLOAD_DRIVE_DIR="$(grep ^pyload-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
FILE_PATH=$(echo ${LOCAL_PATH} | sed 's:[^/]*$::') | ||
DEST_PATH_SUFFIX="${FILE_PATH#"${DOWNLOAD_DIR%/}"}" | ||
if [[ "${PYLOAD_DRIVE_DIR}" =~ :/ ]]; then | ||
REMOTE_PATH="${PYLOAD_DRIVE_DIR}${DEST_PATH_SUFFIX}" | ||
else | ||
if [ "${PYLOAD_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/pyload | ||
else | ||
DRIVE_DIR=${PYLOAD_DRIVE_DIR} | ||
fi | ||
REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}${DEST_PATH_SUFFIX}" | ||
fi | ||
} | ||
|
||
UPLOAD_MODE="$(grep ^pyload-download-finished-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DELETE_EMPTY_DIR="$(grep ^delete-empty-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DRIVE_NAME="$(grep ^drive-name /mnt/data/config/script.conf | cut -d= -f2-)" | ||
PYLOAD_DOWNLOAD_DIR="$(grep ^'.*folder storage_folder' /workdir/.pyload/settings/pyload.cfg | cut -d= -f2- | sed "s/\r$//")" | ||
|
||
DRIVE_NAME_AUTO="$(sed -n '1p' /mnt/data/config/rclone.conf | sed "s/.*\[//g;s/\].*//g;s/\r$//")" | ||
if [ "${DRIVE_NAME}" = "auto" ]; then | ||
DRIVENAME=${DRIVE_NAME_AUTO} | ||
else | ||
DRIVENAME=${DRIVE_NAME} | ||
fi | ||
|
||
GLOBAL_DRIVE_DIR="$(grep ^drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
PYLOAD_DRIVE_DIR="$(grep ^pyload-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
|
||
if [ "${PYLOAD_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/pyload | ||
else | ||
DRIVE_DIR=${PYLOAD_DRIVE_DIR} | ||
fi | ||
|
||
FILE_PATH=$(echo $3 | sed 's:[^/]*$::') | ||
DEST_PATH_SUFFIX="${FILE_PATH#"${PYLOAD_DOWNLOAD_DIR%/}"}" | ||
REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}${DEST_PATH_SUFFIX}" | ||
|
||
if [ "${UPLOAD_MODE}" = "disable" ]; then | ||
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled" | ||
else | ||
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' | ||
UPLOAD_TASK() { | ||
if [ "${UPLOAD_MODE}" = "disable" ]; then | ||
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled" | ||
else | ||
echo "$(DATE_TIME) [ERROR] Failed to send job to rclone: $3" | ||
UPLOAD_FILE | ||
fi | ||
fi | ||
} | ||
|
||
if [[ "${DELETE_EMPTY_DIR}" = "true" ]]; then | ||
find ${PYLOAD_DOWNLOAD_DIR} -depth -mindepth 1 -type d -empty -exec rm -vrf {} \; 2>/dev/null | ||
fi | ||
GET_PATH | ||
DEFINITION_PATH | ||
UPLOAD_TASK | ||
CLEAN_EMPTY_DIR |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,37 @@ | ||
#!/bin/sh | ||
|
||
DATE_TIME() { | ||
date +"%m/%d %H:%M:%S" | ||
#!/bin/bash | ||
# | ||
# Created by wy580477 for customized container <https://github.com/wy580477> | ||
# | ||
|
||
LOCAL_PATH="$3" | ||
PACKAGE_NAME="$2" | ||
source /workdir/script_core.sh | ||
|
||
DEFINITION_PATH() { | ||
UPLOAD_MODE="$(grep ^pyload-package-extracted-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DOWNLOAD_DIR="$(grep ^'.*folder storage_folder' /workdir/.pyload/settings/pyload.cfg | cut -d= -f2- | sed "s/\r$//")" | ||
PYLOAD_DRIVE_DIR="$(grep ^pyload-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
if [[ "${PYLOAD_DRIVE_DIR}" =~ :/ ]]; then | ||
REMOTE_PATH="${PYLOAD_DRIVE_DIR}/${PACKAGE_NAME}" | ||
else | ||
if [ "${PYLOAD_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/pyload | ||
else | ||
DRIVE_DIR=${PYLOAD_DRIVE_DIR} | ||
fi | ||
REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}/${PACKAGE_NAME}" | ||
fi | ||
} | ||
|
||
UPLOAD_MODE="$(grep ^pyload-package-extracted-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DELETE_EMPTY_DIR="$(grep ^delete-empty-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DRIVE_NAME="$(grep ^drive-name /mnt/data/config/script.conf | cut -d= -f2-)" | ||
PYLOAD_DOWNLOAD_DIR="$(grep ^'.*folder storage_folder' /workdir/.pyload/settings/pyload.cfg | cut -d= -f2- | sed "s/\r$//")" | ||
|
||
DRIVE_NAME_AUTO="$(sed -n '1p' /mnt/data/config/rclone.conf | sed "s/.*\[//g;s/\].*//g;s/\r$//")" | ||
if [ "${DRIVE_NAME}" = "auto" ]; then | ||
DRIVENAME=${DRIVE_NAME_AUTO} | ||
else | ||
DRIVENAME=${DRIVE_NAME} | ||
fi | ||
|
||
GLOBAL_DRIVE_DIR="$(grep ^drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
PYLOAD_DRIVE_DIR="$(grep ^pyload-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
|
||
if [ "${PYLOAD_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/pyload | ||
else | ||
DRIVE_DIR=${PYLOAD_DRIVE_DIR} | ||
fi | ||
|
||
REMOTE_PATH="${DRIVENAME}:${DRIVE_DIR}" | ||
|
||
if [ "${UPLOAD_MODE}" = "disable" ]; then | ||
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled" | ||
else | ||
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' | ||
UPLOAD_TASK() { | ||
if [ "${UPLOAD_MODE}" = "disable" ]; then | ||
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled" | ||
else | ||
echo "$(DATE_TIME) [ERROR] Failed to send job to rclone: $3" | ||
UPLOAD_FOLDER | ||
fi | ||
fi | ||
} | ||
|
||
if [[ "${DELETE_EMPTY_DIR}" = "true" ]]; then | ||
find ${PYLOAD_DOWNLOAD_DIR} -depth -mindepth 1 -type d -empty -exec rm -vrf {} \; 2>/dev/null | ||
fi | ||
GET_PATH | ||
DEFINITION_PATH | ||
UPLOAD_TASK | ||
CLEAN_EMPTY_DIR |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,46 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
# | ||
# Created by wy580477 for customized container <https://github.com/wy580477> | ||
# | ||
|
||
UPLOAD_MODE="$(grep ^qbit-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DELETE_EMPTY_DIR="$(grep ^delete-empty-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DRIVE_NAME="$(grep ^drive-name /mnt/data/config/script.conf | cut -d= -f2-)" | ||
QBIT_DOWNLOAD_DIR="$(grep ^'Session\\\DefaultSavePath' /mnt/data/config/qBittorrent/config/qBittorrent.conf | cut -d= -f2- | sed "s/\r$//")" | ||
LOCAL_PATH="$1" | ||
source /workdir/script_core.sh | ||
|
||
DRIVE_NAME_AUTO="$(sed -n '1p' /mnt/data/config/rclone.conf | sed "s/.*\[//g;s/\].*//g;s/\r$//")" | ||
if [ "${DRIVE_NAME}" = "auto" ]; then | ||
DRIVENAME=${DRIVE_NAME_AUTO} | ||
else | ||
DRIVENAME=${DRIVE_NAME} | ||
fi | ||
|
||
GLOBAL_DRIVE_DIR="$(grep ^drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
QBIT_DRIVE_DIR="$(grep ^qbit-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
|
||
if [ "${QBIT_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/qBittorrent | ||
else | ||
DRIVE_DIR=${QBIT_DRIVE_DIR} | ||
fi | ||
|
||
FILE_NAME="$(basename "$1")" | ||
FILE_PATH="$(echo $1 | sed 's:[^/]*$::')" | ||
DEST_PATH_SUFFIX="${FILE_PATH#"${QBIT_DOWNLOAD_DIR%/}"}" | ||
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 | ||
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' | ||
DEFINITION_PATH() { | ||
UPLOAD_MODE="$(grep ^qbit-upload-mode /mnt/data/config/script.conf | cut -d= -f2-)" | ||
DOWNLOAD_DIR="$(grep ^'Session\\\DefaultSavePath' /mnt/data/config/qBittorrent/config/qBittorrent.conf | cut -d= -f2- | sed "s/\r$//")" | ||
QBIT_DRIVE_DIR="$(grep ^qbit-drive-dir /mnt/data/config/script.conf | cut -d= -f2-)" | ||
FILE_NAME="$(basename "${LOCAL_PATH}")" | ||
FILE_PATH="$(echo ${LOCAL_PATH} | sed 's:[^/]*$::')" | ||
DEST_PATH_SUFFIX="${FILE_PATH#"${DOWNLOAD_DIR%/}"}" | ||
if [[ "${QBIT_DRIVE_DIR}" =~ :/ ]]; then | ||
REMOTE_PATH_PREFIX="${QBIT_DRIVE_DIR}" | ||
else | ||
echo "[ERROR] Failed to send job to rclone: $1" | ||
if [ "${QBIT_DRIVE_DIR}" = "" ]; then | ||
DRIVE_DIR=${GLOBAL_DRIVE_DIR}/qBittorrent | ||
else | ||
DRIVE_DIR=${QBIT_DRIVE_DIR} | ||
fi | ||
REMOTE_PATH_PREFIX="${DRIVENAME}:${DRIVE_DIR}" | ||
fi | ||
else | ||
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' | ||
if [ -f "${LOCAL_PATH}" ]; then | ||
REMOTE_PATH="${REMOTE_PATH_PREFIX}${DEST_PATH_SUFFIX}" | ||
else | ||
REMOTE_PATH="${REMOTE_PATH_PREFIX}${DEST_PATH_SUFFIX}/${FILE_NAME}" | ||
fi | ||
} | ||
|
||
UPLOAD_TASK() { | ||
if [ "${UPLOAD_MODE}" = "disable" ]; then | ||
echo "$(DATE_TIME) [INFO] Auto-upload to Rclone remote disabled" | ||
elif [ -f "${LOCAL_PATH}" ]; then | ||
UPLOAD_FILE | ||
else | ||
echo "[ERROR] Failed to send job to rclone: $1" | ||
UPLOAD_FOLDER | ||
fi | ||
fi | ||
} | ||
|
||
if [[ "${DELETE_EMPTY_DIR}" = "true" ]]; then | ||
find ${QBIT_DOWNLOAD_DIR} -depth -mindepth 1 -type d -empty -exec rm -vrf {} \; 2>/dev/null | ||
fi | ||
GET_PATH | ||
DEFINITION_PATH | ||
UPLOAD_TASK | ||
CLEAN_EMPTY_DIR |
This file contains 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
Oops, something went wrong.