From 053638f898cd26a7c3c1f10e78dc4ee1adb8ca30 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 28 Apr 2018 16:04:25 +0200 Subject: Prepend to media queue --- custom/uucp-mediaserver/scripts/queue | 45 +++++++++++++++++++++++------------ odin/strm/send_kitty | 2 +- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/custom/uucp-mediaserver/scripts/queue b/custom/uucp-mediaserver/scripts/queue index 0ad653ff..ea294a6d 100755 --- a/custom/uucp-mediaserver/scripts/queue +++ b/custom/uucp-mediaserver/scripts/queue @@ -44,20 +44,30 @@ base=$(basename $0) suffix=${base##*.} force=0 -if [[ "$1" == "-f" ]]; then - shift - force=1 - if [[ -n "$1" && "$1" -eq "$1" ]] 2>/dev/null; then - force="$1" - shift - fi -fi - noCall=false -if [[ "$1" == "-r" ]]; then - shift - noCall=true -fi +prepend=false +while getopts "frp" OPT; do + case OPT in + r) + noCall=true + ;; + f) + if [[ ${@:$OPTIND} =~ ^[0-9]+$ ]];then + force=${@:$OPTIND} + OPTIND=$((OPTIND+1)) + else + force=1 + fi + ;; + p) + prepend=true + ;; + \?) + echo "Invalid option -${OPTARG}" >&2 + exit 2 + ;; + esac +done for f (${@}); do f=$(readlink -f ${f}) @@ -68,7 +78,12 @@ for f (${@}); do if uustat | grep -q ${f:t}; then printf "ā€˜%sā€™ is already in uucp queue\n" ${f:t} | warn fi - print -r ${f} >> @queueDir@/${suffix}.queue + + if ${prepend}; then + mv =(print -r ${f}; cat @queueDir@/${suffix}.queue) @queueDir@/${suffix}.queue + else + print -r ${f} >> @queueDir@/${suffix}.queue + fi done offset=1 @@ -85,7 +100,7 @@ while true; do if [[ -n "${file}" ]]; then printf "ā€˜%sā€™ does not exist, skipping\n" "${file}" >&2 printf "Subject: Missing file in %s\n\n%s" $logTag ${file} \ - | sendmail gkleen \ + | sendmail uucp \ && echo "Sent mail." fi advance diff --git a/odin/strm/send_kitty b/odin/strm/send_kitty index 60eb11ec..2eb3e98a 100644 --- a/odin/strm/send_kitty +++ b/odin/strm/send_kitty @@ -37,5 +37,5 @@ fi newFile="${concatDir}/$(date +'%Y-%m-%d-%H-%M-%S').mkv" @ffmpeg@/bin/ffmpeg -safe 0 -f concat -i =(awk $'{ print "file \'"$0"\'" }' ${fList}) -c copy -metadata "description=$(xargs -a ${fList} -- basename -s ".mkv")" ${newFile} -queue.hel -r ${newFile} +queue.hel -p -r ${newFile} ln -vfs $(realpath --relative-to=${lastFile:h} ${newFile}) ${lastFile} -- cgit v1.2.3