From a555aadc33ac7a9fc351274823b78a996c50539c Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 12 Jun 2019 13:12:57 +0200 Subject: [PATCH] add tests and move scripts --- hooks/on-start | 6 +++--- report | 10 +++++++--- scripts/email | 22 ---------------------- scripts/html | 7 ------- 4 files changed, 10 insertions(+), 35 deletions(-) delete mode 100755 scripts/email delete mode 100755 scripts/html diff --git a/hooks/on-start b/hooks/on-start index 07a15c7..47d8994 100755 --- a/hooks/on-start +++ b/hooks/on-start @@ -11,13 +11,13 @@ if ! which envsubst 2>/dev/null >/dev/null; then fi if ! which base64 2>/dev/null >/dev/null; then - printf "Le programme \`envsubst\` est nécessaire. Installer \`coreutils\`.\n" + printf "Le programme \`base64\` est nécessaire. Installer \`coreutils\`.\n" exit 1 fi -if ! which smartcl 2>/dev/null >/dev/null; then - printf "Le programme \`envsubst\` est nécessaire. Installer \`smartmontools\`.\n" +if test -n "$SMART_DEVICES" && ! which smartcl 2>/dev/null >/dev/null; then + printf "Le programme \`smartcl\` est nécessaire. Installer \`smartmontools\`.\n" exit 1 fi diff --git a/report b/report index 390d0bc..0c8439c 100755 --- a/report +++ b/report @@ -26,20 +26,24 @@ REPORT="$( ./scripts/system ./scripts/mount ./scripts/df - ./scripts/smart + + if [ -n "$SMART_DEVICES" ]; then + ./scripts/smart + fi + ./scripts/footer )" if [ -n "$HTML_OUTPUT" ]; then export REPORT - ./scripts/html + ./generators/html fi if [ -n "$EMAIL_RECIPIENT" ]; then export REPORT - ./scripts/email + ./generators/email fi ./hooks/on-finish diff --git a/scripts/email b/scripts/email deleted file mode 100755 index 6395ad9..0000000 --- a/scripts/email +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -. ./helpers/template - -export BOUNDARY="-$(date | md5sum | cut -d ' ' -f 1)" - -( - render_template mail - - if [ -n "$MUNIN_DIRECTORY" -a -d "$MUNIN_DIRECTORY" ]; then - cd "$MUNIN_DIRECTORY" - - for file in *day.png; do - export file - export base64="$(base64 "$file")" - - render_template mail-png-attachment - done - fi - - printf "\n--%s--\n" "$BOUNDARY" -)| sendmail "$EMAIL_RECIPIENT" diff --git a/scripts/html b/scripts/html deleted file mode 100755 index 6cb6fc2..0000000 --- a/scripts/html +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -. ./helpers/template - -export content="$REPORT" - -render_template plain > "$HTML_OUTPUT"