diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-20 15:56:50 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-20 15:56:50 (GMT) |
commit | 270058507061600c4451eab173ab485644430166 (patch) | |
tree | a5ff58a55cf69057d143f193c9a203ea3abbae59 /rhautoimport | |
parent | 9ef9b12bc2ee061c9e242ca7236deeac587691b0 (diff) |
improved title and last-run reporting
Diffstat (limited to 'rhautoimport')
-rwxr-xr-x | rhautoimport | 74 |
1 files changed, 28 insertions, 46 deletions
diff --git a/rhautoimport b/rhautoimport index 93d7823..6214348 100755 --- a/rhautoimport +++ b/rhautoimport @@ -26,51 +26,13 @@ if [ -z "$1" ]; then exit 1 fi -TITLE="unknown" -case "$1" in - btl) - TITLE="Between the Lines" - ;; - dn) - TITLE="Democracy Now!" - ;; - er) - TITLE="Ergo" - ;; - eu) - TITLE="Economic Update" - ;; - fl) - TITLE="Frequenz Leitwolf" - ;; - nw) - TITLE="netwatcher" - ;; - oi) - TITLE="Onda-Info" - ;; - po) - TITLE="Panoptikum" - ;; - ra) - TITLE="radio%attac" - ;; - rs) - TITLE="Radio Stimme" - ;; - tr) - TITLE="Tierrechtsradio" - ;; - wr) - TITLE="Werkstatt-Radio" - ;; - *) - echo "unknown importer: $1" - exit 2 - ;; -esac +if [ ! -x "/usr/bin/rhautoimport-$1" ]; then + echo "unknown importer: $1" + exit 2 +fi LOG_FILE=`mktemp --tmpdir rhautoimport-XXXXXX.log` +RESULT_FILE=`mktemp --tmpdir rhautoimport-XXXXXX.result` MAIL_TO=`sed 's/#.*//' /etc/rhautoimport/$1.mail 2> /dev/null | xargs` if [ -z "$MAIL_TO" ]; then MAIL_TO="root" @@ -79,8 +41,28 @@ fi ( /usr/bin/flock -x -w 10 200 - /usr/bin/rhautoimport-$1 ${@:2} > $LOG_FILE 2>&1 - case $? in + /usr/bin/rhautoimport-$1 ${@:2} > $LOG_FILE 2>&1 3> $RESULT_FILE + RETURN_CODE=$? + TITLE="" + WAS_LAST=0 + idx=0 + while IFS= read -r line; do + case $idx in + 0) + TITLE=$line + ;; + 1) + WAS_LAST=$line + ;; + *) + break + ;; + esac + idx=$((idx+1)) + done < $RESULT_FILE + rm -f $RESULT_FILE + + case $RETURN_CODE in 0) bsd-mailx -a "Content-Type: text/plain; charset=utf-8" -s "$TITLE - Imported Successfully" $MAIL_TO < $LOG_FILE ;; @@ -91,7 +73,7 @@ fi # do nothing - the script didn't import anything but no message should be sent ;; *) - if [ "$2" == 'last' ]; then + if [ $WAS_LAST -eq 1 ]; then subject="$TITLE - Import Error - last attempt!!!" else subject="$TITLE - Import Error - will retry" |