diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-10-17 16:04:48 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-10-17 16:04:48 +0200 |
commit | 5842ea263ed3a8b3f4d8bfc5b20d8dbfd70464a8 (patch) | |
tree | 9492a9cd2d2f835ba133aa1021ea6f641f46c1f7 | |
parent | 14488b0d6d749554fc493e99913b730bea7116a6 (diff) | |
download | impressive-display-5842ea263ed3a8b3f4d8bfc5b20d8dbfd70464a8.tar.gz impressive-display-5842ea263ed3a8b3f4d8bfc5b20d8dbfd70464a8.tar.bz2 impressive-display-5842ea263ed3a8b3f4d8bfc5b20d8dbfd70464a8.zip |
impressive-display: Provide means for logging to syslog.
-rwxr-xr-x | bin/impressive-display | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/bin/impressive-display b/bin/impressive-display index cf255e1..cc7b07c 100755 --- a/bin/impressive-display +++ b/bin/impressive-display @@ -78,6 +78,8 @@ DOWNLOAD_INTERVAL="600" RUSH_HOURS="07-11" RUSH_HOURS_DOWNLOAD_INTERVAL="180" +LOG_TO_SYSLOG= + # Disable PDF downloads at night time completely... SLEEP_HOURS="22-06" SLEEP_HOURS_DOWNLOAD_INTERVAL="0" @@ -103,6 +105,12 @@ if [ -r $HOME/.impressive-display-rc ] && [ ! -d $HOME/.impressive-display-rc ]; . $HOME/.impressive-display fi +if [ -z "$LOG_TO_SYSLOG" ]; then + OUTPUT="echo" +else + OUTPUT="logger -t impressive-display" +fi + workdir="$HOME/.impressive-display" mkdir -p "$workdir" pdffile_previous="$workdir/impressive-pdffile-previous.pdf" @@ -202,7 +210,7 @@ function cleanup { function pdf_is_portrait { if ! which bc 1>/dev/null; then - echo "WARNING: The 'bc' command line tool is not installed on this system." + $OUTPUT "WARNING: The 'bc' command line tool is not installed on this system." return -1 fi @@ -239,7 +247,7 @@ function merge_portrait_documents { cp "$pdffile_downloaded" "$pdffile_display" fi else - echo "WARNING: The pdfnup tool is not installed." + $OUTPUT "WARNING: The pdfnup tool is not installed." cp "$pdffile_downloaded" "$pdffile_display" fi @@ -341,7 +349,7 @@ function download_pdffile { else - echo "WARNING: PDF file format problems. Maybe not a PDF file?" + $OUTPUT "WARNING: PDF file format problems. Maybe not a PDF file?" fi @@ -358,30 +366,30 @@ function download_loop { while [ -e "$session_lock" ]; do if [ -n "$DEBUG_DOWNLOADS" ]; then - echo "DEBUG: rush hour: `is_rush_hour` (interval: $RUSH_HOURS_DOWNLOAD_INTERVAL), sleep hour: `is_sleep_hour` (interval: $SLEEP_HOURS_DOWNLOAD_INTERVAL). Normal interval: $DOWNLOAD_INTERVAL." + $OUTPUT "DEBUG: rush hour: `is_rush_hour` (interval: $RUSH_HOURS_DOWNLOAD_INTERVAL), sleep hour: `is_sleep_hour` (interval: $SLEEP_HOURS_DOWNLOAD_INTERVAL). Normal interval: $DOWNLOAD_INTERVAL." fi if is_rush_hour 1>/dev/null && [ "x$RUSH_HOURS_DOWNLOAD_INTERVAL" != "x0" ]; then sleep $RUSH_HOURS_DOWNLOAD_INTERVAL if [ -n "$DEBUG_DOWNLOADS" ]; then - echo "RUSH HOUR download, URL: $PDF_URL" + $OUTPUT "INFO: RUSH HOUR download, URL: $PDF_URL" fi download_pdffile elif is_sleep_hour 1>/dev/null && [ "x$SLEEP_HOURS_DOWNLOAD_INTERVAL" != "x0" ]; then sleep $SLEEP_HOURS_DOWNLOAD_INTERVAL if [ -n "$DEBUG_DOWNLOADS" ]; then - echo "SLEEP HOUR download, URL: $PDF_URL" + $OUTPUT "INFO: SLEEP HOUR download, URL: $PDF_URL" fi download_pdffile elif (! is_rush_hour 1>/dev/null ) && (! is_sleep_hour 1>/dev/null) && [ "x$DOWNLOAD_INTERVAL" != "x0" ]; then sleep $DOWNLOAD_INTERVAL if [ -n "$DEBUG_DOWNLOADS" ]; then - echo "NORMAL HOUR download, URL: $PDF_URL" + $OUTPUT "INFO: NORMAL HOUR download, URL: $PDF_URL" fi download_pdffile else if [ -n "$DEBUG_DOWNLOADS" ]; then - echo "DEBUG: Not doing any download." + $OUTPUT "DEBUG: Not doing any download." fi sleep 60 fi @@ -416,7 +424,7 @@ function reloadable_impressive { done else - echo "ERROR: The impressive application is not installed." + $OUTPUT "ERROR: The impressive application is not installed." fi } @@ -432,23 +440,23 @@ function create_lock { ### MAIN ### -echo "INFO: $(basename $0) version $VERSION" +$OUTPUT "INFO: $(basename $0) version $VERSION" if [ -n "$PDF_URL" ]; then - echo "INFO: PDF_URL is configured. Using PDF file from given URL: $PDF_URL" + $OUTPUT "INFO: PDF_URL is configured. Using PDF file from given URL: $PDF_URL" create_lock download_loop elif [ -n "$PDF_FILE" ]; then - echo "INFO: PDF_FILE is configured. Using local PDF file: $PDF_FILE" + $OUTPUT "INFO: PDF_FILE is configured. Using local PDF file: $PDF_FILE" create_lock local_pdffile else - echo "ERROR: Neither PDF_FILE nor PDF_URL has been configured. Doing nothing." + $OUTPUT "ERROR: Neither PDF_FILE nor PDF_URL has been configured. Doing nothing." exit 0 fi |