From 818f7abbe274ce21116addded15d57315aa6ecbb Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 2 May 2019 20:41:03 +0200 Subject: [PATCH] initial --- boot.sh | 6 ++++++ bot.sh | 10 ++++++++++ func.sh | 9 +++++++++ 3 files changed, 25 insertions(+) create mode 100755 boot.sh create mode 100755 bot.sh create mode 100755 func.sh diff --git a/boot.sh b/boot.sh new file mode 100755 index 0000000..dd2c30d --- /dev/null +++ b/boot.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +#notify on reboot + +. func.sh +send "Server%20started." diff --git a/bot.sh b/bot.sh new file mode 100755 index 0000000..30ca692 --- /dev/null +++ b/bot.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# the main bot script + +#hdd usage +used=$(df --output=pcent /dev/sda3 | tail -1 | grep -Po "(\\d+)" --color=never) +if [ "$used" -gt 50 ]; then + . func.sh + echo "warn!" + send "warnung%20server%20used%20$used%25%20of%20the%20storage!" +fi diff --git a/func.sh b/func.sh new file mode 100755 index 0000000..fd06586 --- /dev/null +++ b/func.sh @@ -0,0 +1,9 @@ +#!/bin/bash +token="APItoken" +userid="usernameorid" + +#1. arg = text +send() { + echo "Sending $1 to ${userid}" + curl -s "https://api.telegram.org/bot${token}/sendMessage?chat_id=${userid}&text=$1" > /dev/null +}