From 4f80e34663a806581fba895386cb12e75743aedd Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Thu, 23 Apr 2020 14:52:30 +0000 Subject: [PATCH] new storage log cron, discord now supports newlines, etc. --- config.example.sh | 4 ++++ crons/storage-log.sh | 11 +++++++++++ discord.sh | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 crons/storage-log.sh diff --git a/config.example.sh b/config.example.sh index 741f27d..e2521c6 100644 --- a/config.example.sh +++ b/config.example.sh @@ -3,6 +3,10 @@ # degrees in C THERMAL_ALERT=75 +STORAGE_MONITOR=("/") + +SERVER_DOMAIN="localhost" + DISCORD_SERVER_NAME="" DISCORD_GENERAL_HOOK="" diff --git a/crons/storage-log.sh b/crons/storage-log.sh new file mode 100755 index 0000000..1af4c08 --- /dev/null +++ b/crons/storage-log.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +LOCATION=`dirname "$0"` + +source "${LOCATION}/../config.sh" + +storage=`${LOCATION}/../df-custom.sh ${STORAGE_MONITOR[@]}` + +echo "${storage}" +${LOCATION}/../discord.sh storage "${storage}" + diff --git a/discord.sh b/discord.sh index f9ae6f1..12698f5 100755 --- a/discord.sh +++ b/discord.sh @@ -5,7 +5,7 @@ LOCATION=`dirname "$0"` source "${LOCATION}/config.sh" HOOK_ARG="$1" -MESSAGE="${@:2}" +MESSAGE=`echo "${@:2}" | jq -aRs .` HOOK="general" HOOK_URL=$DISCORD_GENERAL_HOOK @@ -20,5 +20,5 @@ case $HOOK_ARG in ;; esac -curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${DISCORD_SERVER_NAME}\", \"content\": \"${MESSAGE}\"}" $HOOK_URL | jq -r '.id' +curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${DISCORD_SERVER_NAME}\", \"content\": ${MESSAGE}}" $HOOK_URL | jq -r '.id'