Created
March 9, 2018 13:31
-
-
Save Stadicus/adb431d95c74042b8ab45556cc572232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# part of Thundroid setup | |
# copy to /usr/local/bin/systemd-statusmail.sh | |
# make executable with: sudo chmod +x /usr/local/bin/systemd-statusmail.sh | |
MAILTO="[email protected]" | |
MAILFROM="[email protected]" | |
UNIT=$1 | |
UNITSTATUS=$(systemctl status $UNIT) | |
TIMESTAMP=$(date "+%Y-%m-%d %T") | |
EXTRA="" | |
for e in "${@:2}"; do | |
EXTRA+="$e"$'\n' | |
done | |
sendmail $MAILTO <<EOF | |
From:$MAILFROM | |
To:$MAILTO | |
Subject:Status mail for unit: $UNIT | |
Status report for unit: $UNIT | |
$TIMESTAMP | |
------------------------------------------------------------ | |
$UNITSTATUS | |
------------------------------------------------------------ | |
$EXTRA | |
EOF | |
echo -e "Status mail sent to: $MAILTO for unit: $UNIT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment