#!/bin/bash # # Sends a mail message about shutdown to the Linux user itself. # Hopes the appropriate message forward rule has been set. # # Author: Kovács Zoltán # License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html) # 2021-09-05 v0.1 Initial release MAIL=$(which mail) if [ -n "$MAIL" -a -x "$MAIL" ]; then subject="[Maintenance] A Docker service has been stopped intentionally on $HOSTNAME" message="This is a message from $0 script on $HOSTNAME.\n" message+="This Docker service has been stopped intentionally few seconds ago.\n\n" message+="Best regards: the Maintenance Bot" echo -e "$message" | "$MAIL" -s "$subject" "$USER" fi # That's all, Folks!