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 +++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'custom/uucp-mediaserver/scripts/queue') 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 -- cgit v1.2.3