diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-03-13 04:02:02 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-03-13 04:02:02 (GMT) |
commit | 6dbb44e71bdfb241624b0d722b78139dab98ff27 (patch) | |
tree | 036cd157a17e582f894c97b16f56555195fc082a /rhautoimport | |
parent | 7ffd297bd4120690e45b7aa7d98f9c8472a1b3ec (diff) |
added import launcher
Diffstat (limited to 'rhautoimport')
-rwxr-xr-x | rhautoimport | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/rhautoimport b/rhautoimport new file mode 100755 index 0000000..f7c52c4 --- /dev/null +++ b/rhautoimport @@ -0,0 +1,84 @@ +#!/bin/bash +# +# +# rhautoimport +# +# Copyright (C) 2009-2016 Christian Pointner <equinox@helsinki.at> +# +# This file is part of rhautoimport. +# +# rhautoimport is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# rhautoimport is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rhautoimport. If not, see <http://www.gnu.org/licenses/>. +# + +if [ -z "$1" ]; then + echo "rhautoimport <importer> [ last ]" + exit 1 +fi + +TITLE="unknown" +case "$1" in + btl) + TITLE="Between the Lines" + ;; + dn) + TITLE="Democracy Now!" + ;; + nw) + TITLE="netwatcher" + ;; + oi) + TITLE="Onda-Info" + ;; + ra) + TITLE="radio%attac" + ;; + rs) + TITLE="Radio Stimme" + ;; + tr) + TITLE="Tierrechtsradio" + ;; + *) + echo "unknown importer: $1" + exit 2 + ;; +esac + +LOG_FILE=`mktemp --tmpdir rhautoimport-XXXXXX.log` +MAIL_TO=`cat /etc/rhautoimport/$1.mail 2> /dev/null | xargs` +if [ -z "$MAIL_TO" ]; then + MAIL_TO="root" +fi + +/usr/bin/rhautoimport-$1 $2 > $LOG_FILE 2>&1 +case $? in + 0) + /usr/bin/mail -a "Content-Type: text/plain; charset=utf-8" -s "$TITLE - Imported Successfully" $MAIL_TO < $LOG_FILE + ;; + 42) + # do nothing - the script didn't import anything but no message should be sent + ;; + *) + if [ "$2" == 'last' ]; then + subject="$TITLE - Import Error - last attempt!!!" + else + subject="$TITLE - Import Error - will retry" + fi + /usr/bin/mail -a "Content-Type: text/plain; charset=utf-8" -s "$subject" $MAIL_TO < $LOG_FILE + ;; +esac + +rm -f $LOG_FILE + +exit 0 |