diff --git a/lgsm/modules/alert.sh b/lgsm/modules/alert.sh index 40288d234e..07498aed2d 100644 --- a/lgsm/modules/alert.sh +++ b/lgsm/modules/alert.sh @@ -27,6 +27,17 @@ fn_alert_log() { } | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | tee -a "${alertlog}" > /dev/null 2>&1 } +fn_alert_custom() { + fn_script_log_info "Sending custom alert: Custom alert from ${selfname}." + alertaction="${customalerttitle}" + alertemoji="📢" + alertsound="1" + alertmessage="${customalertmessage}" + # Green + alertcolourhex="#6600CC" + alertcolourdec="6684876" +} + fn_alert_test() { fn_script_log_info "Sending alert: Testing LinuxGSM Alert. No action to be taken" alertaction="Tested" @@ -206,6 +217,8 @@ elif [ "${alert}" == "monitor-session" ]; then fn_alert_monitor_session elif [ "${alert}" == "monitor-query" ]; then fn_alert_monitor_query +elif [ "${alert}" == "custom" ]; then + fn_alert_custom elif [ "${alert}" == "test" ]; then fn_alert_test elif [ "${alert}" == "update" ]; then diff --git a/lgsm/modules/command_custom_alert.sh b/lgsm/modules/command_custom_alert.sh new file mode 100644 index 0000000000..26ba8c9aa4 --- /dev/null +++ b/lgsm/modules/command_custom_alert.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# LinuxGSM command_custom_alert.sh module +# Author: Daniel Gibbs +# Contributors: http://linuxgsm.com/contrib +# Website: https://linuxgsm.com +# Description: Sends a custom alert. + +commandname="CUSTOM-ALERT" +commandaction="Custom Alert" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_firstcommand_set + +check.sh + +if [ -n "${userinput2}" ]; then + customalertmessage="${userinput2}" +else + fn_print_header + fn_print_information_nl "Send a custom alert." + echo "" + customalertmessage=$(fn_prompt_message "alert message: ") +fi + +# optional: custom alert title +if [ -n "${userinput3}" ]; then + customalerttitle="${userinput3}" +else + customalerttitle="Custom Alert" +fi + +info_game.sh +alert="custom" +alert.sh + +core_exit.sh diff --git a/lgsm/modules/core_getopt.sh b/lgsm/modules/core_getopt.sh index cd3e57cb57..9ab974f128 100644 --- a/lgsm/modules/core_getopt.sh +++ b/lgsm/modules/core_getopt.sh @@ -19,6 +19,7 @@ cmd_details=("dt;details" "command_details.sh" "Display server information.") cmd_postdetails=("pd;postdetails" "command_postdetails.sh" "Post details to termbin.com (removing passwords).") cmd_backup=("b;backup" "command_backup.sh" "Create backup archives of the server.") cmd_update_linuxgsm=("ul;update-lgsm;uf;update-modules" "command_update_linuxgsm.sh" "Check and apply any LinuxGSM updates.") +cmd_custom_alert=("ca;custom-alert" "command_custom_alert.sh" "Send a customizable alert.") cmd_test_alert=("ta;test-alert" "command_test_alert.sh" "Send a test alert.") cmd_monitor=("m;monitor" "command_monitor.sh" "Check server status and restart if crashed.") cmd_skeleton=("sk;skeleton" "command_skeleton.sh" "Create a skeleton directory.") @@ -60,7 +61,7 @@ cmd_dev_clear_modules=("cm;clear-modules" "command_dev_clear_modules.sh" "Delete ### Set specific opt here. -currentopt=("${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monitor[@]}" "${cmd_test_alert[@]}" "${cmd_details[@]}" "${cmd_postdetails[@]}" "${cmd_skeleton[@]}") +currentopt=("${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monitor[@]}" "${cmd_custom_alert[@]}" "${cmd_test_alert[@]}" "${cmd_details[@]}" "${cmd_postdetails[@]}" "${cmd_skeleton[@]}") # Update LinuxGSM. currentopt+=("${cmd_update_linuxgsm[@]}") diff --git a/lgsm/modules/core_modules.sh b/lgsm/modules/core_modules.sh index 7ea0402e35..13505ae5e8 100644 --- a/lgsm/modules/core_modules.sh +++ b/lgsm/modules/core_modules.sh @@ -96,6 +96,11 @@ command_postdetails.sh() { fn_fetch_module } +command_custom_alert.sh() { + modulefile="${FUNCNAME[0]}" + fn_fetch_module +} + command_test_alert.sh() { modulefile="${FUNCNAME[0]}" fn_fetch_module diff --git a/linuxgsm.sh b/linuxgsm.sh index c68f19dc23..6245b4da37 100755 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -48,6 +48,7 @@ configdirserver="${configdir}/${gameservername}" configdirdefault="${lgsmdir}/config-default" userinput="${1}" userinput2="${2}" +userinput3="${3}" ## GitHub Branch Select # Allows for the use of different function files