57 lines
2.8 KiB
Bash
Executable file
57 lines
2.8 KiB
Bash
Executable file
#! Name: CatnapCtrlC.sh
|
|
#! Author: kittykat
|
|
#! Version: 2024.09.21
|
|
#! Desc: Keeps mad.sh running until Ctrl-C, waiting for urls.txt updates
|
|
#! Usage: Edit LoadPlugin="" line in mad.sh or mad.config
|
|
#! LoadPlugin="CatnapCtrlC.sh"
|
|
#! Notes:
|
|
#! * Return 0 (true), continue script (exit)
|
|
#! * Return 1 (false), return to processing the beginning of urls.txt -- would be used with a sleep
|
|
#! to continue to run indefinitely until Ctrl-C is pressed, waiting for more urls
|
|
#!
|
|
#! Plugin System: Additional Hook Functions added for easy of overriding:
|
|
#!
|
|
#! To Hook a Function, your function must begin with the hookable function name, and be unique
|
|
#! Best practice: HooKFuncName_<yourfilename>
|
|
#! ie.
|
|
#! PostSuccessfulDownload_myfilename() {
|
|
#! }
|
|
#!
|
|
#! Available Hook Functions:
|
|
#! -------------------------
|
|
#! * OnLoad(): Occurs after load mad.config / load plugins (prior to processing).
|
|
#! * BeginProcessing(): Occurs immediately after beginning processin of urls.txt (loops with Catnaps).
|
|
#! * PreProcessUrl(): occurs immediately after reading in an unprocessed url (^http) line to process.
|
|
#! * PostSuccessfulDownload(): occurs after a download success (is marked #OK# in the urls.txt).
|
|
#! * PostFailedDownload(): occurs after a download fails (is marked #FAIL# in the urls.txt).
|
|
#! * PostFailRetryDownload(): occurs after a download fails with a retry (is marked #RETRY# in the urls.txt).
|
|
#! * DoneProcessingAllUrls(): occurs after all the urls have finished processing (no flocks or other terms downloading).
|
|
#! * PostSuccessfulUpload(): occurs after an upload success (after upload completed ticket is created in ./downloads/).
|
|
#! * PostFailedUpload(): occurs after an upload fails definitively -- #FAIL# in the temp_upload_handler.txt
|
|
#! * PostFailRetryUpload(): occurs after an upload fails with a retry (network drop, unexpected result)
|
|
#! * DoneProcessingAllUploads: occurs after alll the files have finished processing
|
|
#!
|
|
DoneProcessingAllUrls_CatnapCtrlC() {
|
|
local plugName='CatnapCtrlC'
|
|
local plugFunc='DoneProcessingAllUrls_CatnapCtrlC'
|
|
if [ "${DebugPluginsEnabled}" == "true" ]; then
|
|
echo -e "[${PINK}DEBUG${NC}]: Running ${PINK}$plugFunc${NC} in ${BLUE}$plugName${NC} ...${NC}"
|
|
fi
|
|
local pInputFile="$1"
|
|
CatnapCount=$((CatnapCount + 1))
|
|
if ((CatnapCount > 2)); then
|
|
for ((a=1; a<=2; a++)); do
|
|
printf "\033[1A\r"
|
|
printf "\33[2K\r"
|
|
done
|
|
elif ((CatnapCount > 1)); then
|
|
for ((a=1; a<=5; a++)); do
|
|
printf "\033[1A\r"
|
|
printf "\33[2K\r"
|
|
done
|
|
fi
|
|
echo -e "${NC}"
|
|
echo -e "${YELLOW}Ctrl-C Catnapping${NC} for ${CatnapDuration} mins and waiting for urls in ${YELLOW}${pInputFile}${NC}... ${YELLOW}zZzZzZ${NC} ${BLUE}x$CatnapCount${NC}"
|
|
sleep ${CatnapDuration}m
|
|
return 1
|
|
}
|