Skip to content

Instantly share code, notes, and snippets.

@Stadicus
Created March 9, 2018 13:31
Show Gist options
  • Save Stadicus/adb431d95c74042b8ab45556cc572232 to your computer and use it in GitHub Desktop.
Save Stadicus/adb431d95c74042b8ab45556cc572232 to your computer and use it in GitHub Desktop.
#!/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