Add notifyCommand

This commit is contained in:
Ben Peddell 2020-02-22 20:40:55 +10:00
parent f26ae1e56f
commit e11cc9952a
3 changed files with 11 additions and 0 deletions

View File

@ -617,6 +617,11 @@ The following options can be overridden on a per-instance basis:
`noNotifyWarn`::
Disable notification at start of shutdown warning period
`notifyCommand`::
Notify command to run. Notify message will be in `${notifymsg}`, and templated message will be in `${msg}`
+
e.g. `notifyCommand='echo "$msg" | mailx -s "Message from instance ${instance} on server ${HOSTNAME}" "email@domain.com"'`
`logdir`::
Specifies where to store log files

View File

@ -580,6 +580,7 @@ function notifyOverride(){
function notify(){
if [[ -n "$1" && "$1" != "-" ]]; then
local msg
local notifymsg="$1"
msg="${notifyTemplate:-Message from instance \`{instance\}\` on server \`{server\}\`: {msg\}}"
msg="${msg//\{msg\}/${1}}"
msg="${msg//\{instance\}/${instance}}"
@ -592,6 +593,10 @@ function notify(){
notifyDiscord "$msg"
notifyOverride "$msg"
if [ -n "${notifyCommand}" ]; then
eval " ${notifyCommand}"
fi
fi
}

View File

@ -48,6 +48,7 @@ msgWarnCancelled="Restart cancelled by player request"
# notifyMsgServerTerminated="Server exited - restarting"
# notifyTemplate="Message from instance {instance} on server {server}: {msg}"
# noNotifyWarning=true
# notifyCommand='echo "$msg" | mailx -s "Message from instance ${instance} on server ${HOSTNAME}" "email@domain.com"'
# Restart cancel chat command
#chatCommandRestartCancel="/cancelupdate"