Browse Source

add tests and move scripts

develop
Simon Vieille 2 years ago
parent
commit
a555aadc33
Signed by: deblan GPG Key ID: 03383D15A1D31745
  1. 6
      hooks/on-start
  2. 10
      report
  3. 22
      scripts/email
  4. 7
      scripts/html

6
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

10
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

22
scripts/email

@ -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"

7
scripts/html

@ -1,7 +0,0 @@
#!/bin/sh
. ./helpers/template
export content="$REPORT"
render_template plain > "$HTML_OUTPUT"
Loading…
Cancel
Save