forked from HPR/hpr-tools
		
	Updates for show "repair" processing
InternetArchive/future_upload: Added logging and debugging
InternetArchive/ia_db.sql: Added new tables
InternetArchive/recover_transcripts: New script to run on 'borg' and
    copy missing files from the backup disk to the IA
InternetArchive/repair_assets: More comments, including one about a bug in the design.
InternetArchive/repair_item: Fix relating to octal numbers (if there are
    leading zeroes in a number). '_DEBUG' is now in the function
    library. Added comments to explain obscure stuff.
InternetArchive/snapshot_metadata: New Bash script (to run on my
    desktop) which collects metadata for a show and stores in in the
    '~/HPR/IA/assets' directory. Runs 'view_derivatives' on it to find
    derivative files for deletion.
InternetArchive/tidy_uploaded: Moves files and directories containing
    uploaded files into a holding area for later backup. Added
    debugging, logging and a 'force' mode.
InternetArchive/upload_manager: Manages 'ia.db' (on my workstation).
    Needs many updates which have just started to be added.
InternetArchive/weekly_upload: Old script, now obsolete.
			
			
This commit is contained in:
		| @@ -13,9 +13,9 @@ | ||||
| #        NOTES: Contains methods from 'delete_uploaded' and 'weekly_upload' as | ||||
| #               well as 'update_state' | ||||
| #       AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com | ||||
| #      VERSION: 0.0.14 | ||||
| #      VERSION: 0.0.15 | ||||
| #      CREATED: 2021-01-07 12:11:02 | ||||
| #     REVISION: 2024-03-03 14:12:30 | ||||
| #     REVISION: 2024-07-29 23:17:45 | ||||
| # | ||||
| #=============================================================================== | ||||
|  | ||||
| @@ -26,7 +26,7 @@ SCRIPT=${0##*/} | ||||
|  | ||||
| STDOUT="/dev/fd/2" | ||||
|  | ||||
| VERSION="0.0.14" | ||||
| VERSION="0.0.15" | ||||
|  | ||||
| # | ||||
| # Load library functions | ||||
| @@ -36,6 +36,8 @@ LIB="$HOME/bin/function_lib.sh" | ||||
| # shellcheck disable=SC1090 | ||||
| source "$LIB" | ||||
|  | ||||
| # {{{ -- Functions -- check_uploads, _log, _usage | ||||
|  | ||||
| #===  FUNCTION  ================================================================ | ||||
| #         NAME: check_uploads | ||||
| #  DESCRIPTION: Determines if files exist for uploading | ||||
| @@ -59,6 +61,31 @@ check_uploads () { | ||||
|     return 0 | ||||
| } | ||||
|  | ||||
| #===  FUNCTION  ================================================================ | ||||
| #         NAME: _log | ||||
| #  DESCRIPTION: Writes a log record to the predefined $LOGFILE in this script | ||||
| #               using the predefined $LOGREC, a template for 'printf'. If the | ||||
| #               latter is not defined the function will use a default. | ||||
| #               For some reason 'shellcheck' objects to this function. The | ||||
| #               first argument to 'printf' needs to be -1 to make the | ||||
| #               '%(fmt)T' use today's date and time. | ||||
| #   PARAMETERS: 1 - the message to write | ||||
| #      RETURNS: Nothing | ||||
| #=============================================================================== | ||||
| # shellcheck disable=SC2317 disable=SC2059 | ||||
| _log () { | ||||
|     local msg="$1" | ||||
|  | ||||
| #     echo "D> $LOGFILE $LOGREC" | ||||
|     [ -v LOGFILE ] || { echo "${FUNCNAME[0]}: \$LOGFILE is not defined"; exit 1; } | ||||
|     [ -v LOGREC ] || { local LOGREC='%(%F %T)T %s\n'; } | ||||
|  | ||||
| #     echo "D> $LOGFILE $LOGREC" | ||||
|     printf "$LOGREC" -1 "$msg" >> "$LOGFILE" | ||||
|  | ||||
|     return | ||||
| } | ||||
|  | ||||
| #===  FUNCTION  ================================================================ | ||||
| #         NAME: _usage | ||||
| #  DESCRIPTION: Report usage | ||||
| @@ -108,18 +135,7 @@ endusage | ||||
|     exit "$res" | ||||
| } | ||||
|  | ||||
| #===  FUNCTION  ================================================================ | ||||
| #         NAME: _DEBUG | ||||
| #  DESCRIPTION: Writes a message if in DEBUG mode | ||||
| #   PARAMETERS: List of messages | ||||
| #      RETURNS: Nothing | ||||
| #=============================================================================== | ||||
| _DEBUG () { | ||||
|     [ "$DEBUG" == 0 ] && return | ||||
|     for msg in "$@"; do | ||||
|         printf 'D> %s\n' "$msg" | ||||
|     done | ||||
| } | ||||
| # }}} | ||||
|  | ||||
| #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
| @@ -144,6 +160,7 @@ cd "$BASEDIR" || { echo "Can't cd to $BASEDIR"; exit 1; } | ||||
| # | ||||
| LOGS="$BASEDIR/logs" | ||||
| LOGFILE="$LOGS/$SCRIPT.log" | ||||
| LOGREC='%(%F %T)T %s\n' | ||||
|  | ||||
| # | ||||
| # Tools | ||||
| @@ -157,8 +174,8 @@ UPSTATE="$BASEDIR/update_state" | ||||
| # | ||||
| # Fallback URL | ||||
| # | ||||
| URL_BAK="http://hub.hackerpublicradio.org/cms/status.php" | ||||
| QUERY2_BAK="${BASECOM} -o - ${URL_BAK}" | ||||
| # URL_BAK="http://hub.hackerpublicradio.org/cms/status.php" | ||||
| # QUERY2_BAK="${BASECOM} -o - ${URL_BAK}" | ||||
|  | ||||
| # | ||||
| # Prerequisites | ||||
| @@ -575,4 +592,4 @@ fi | ||||
|  | ||||
| exit | ||||
|  | ||||
| # vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21 | ||||
| # vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21:fdm=marker | ||||
|   | ||||
		Reference in New Issue
	
	Block a user