From f20f1349c55d060fc1ddaf7491552e743df567b8 Mon Sep 17 00:00:00 2001 From: samuel-p Date: Wed, 30 Dec 2020 01:58:16 +0100 Subject: [PATCH] added update-notify.sh added node_dir_size_exporter.sh --- node_dir_size_exporter.sh | 8 ++++++++ update-notify.sh | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 node_dir_size_exporter.sh create mode 100644 update-notify.sh diff --git a/node_dir_size_exporter.sh b/node_dir_size_exporter.sh new file mode 100644 index 0000000..7ee98e5 --- /dev/null +++ b/node_dir_size_exporter.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +DIR=$1 +KEY=$2 +FILE=$3 + +du -bsx $DIR | sed "s/\([0-9]*\).*\/\(.*\)/node_dir_size{name=\"\2\",key=\"$KEY\"} \1/" > "$FILE$$" +mv "$FILE$$" "$FILE" diff --git a/update-notify.sh b/update-notify.sh new file mode 100644 index 0000000..d31f4eb --- /dev/null +++ b/update-notify.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +GOTIFY_FILE=$(<~/.gotify) +GOTIFY_TOKEN=${GOTIFY_FILE##*( )} +HOST="$(hostname)" +TITLE="Updates available on $HOST" + +if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit +fi + +apt update + +UPDATE=$(apt list --upgradable) + +echo "$UPDATE" + +if [[ $UPDATE == *$'\n'* ]]; then + curl -F "title=$TITLE" -F "message=$UPDATE" -F "priority=5" "https://push.sp-codes.de/message?token=$GOTIFY_TOKEN" +fi