diff --git a/lgsm/modules/alert.sh b/lgsm/modules/alert.sh index b53ff040c..b90f88f04 100644 --- a/lgsm/modules/alert.sh +++ b/lgsm/modules/alert.sh @@ -190,12 +190,24 @@ elif [ "${alert}" == "update" ]; then fn_alert_update elif [ "${alert}" == "check-update" ]; then fn_alert_check_update -elif [ "${alert}" == "update-restart" ]; then - fn_alert_update_restart elif [ "${alert}" == "config" ]; then fn_alert_config elif [ "${alert}" == "wipe" ]; then fn_alert_wipe +elif [ "${alert}" == "info" ]; then + fn_alert_info +elif [ "${alert}" == "started" ]; then + fn_alert_started +elif [ "${alert}" == "stopped" ]; then + fn_alert_stopped +elif [ "${alert}" == "restarted" ]; then + fn_alert_restarted +elif [ "${alert}" == "update-linuxgsm" ]; then + fn_alert_update_linuxgsm +else + fn_print_fail_nl "Missing alert type" + fn_script_log_fatal "Missing alert type" + core_exit.sh fi alerttitle="${alertemoji} ${alertaction} - ${servername} ${alertemoji}" diff --git a/lgsm/modules/alert_rocketchat.sh b/lgsm/modules/alert_rocketchat.sh index c65ba42ed..65d6f1cf6 100644 --- a/lgsm/modules/alert_rocketchat.sh +++ b/lgsm/modules/alert_rocketchat.sh @@ -41,22 +41,39 @@ jsonnoinfo=$( cat << EOF { "alias": "LinuxGSM", - "text": "*${alerttitle}*\nInformation\n${alertmessage}", + "text": "*${alerttitle}*", "attachments": [ { + "title": "", + "color": "${alertcolourhex}", + "author_name": "LinuxGSM Alert", + "author_link": "https://linuxgsm.com", + "author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "thumb_url": "${alerticon}", + "text": "", "fields": [ { - "short": true, + "short": false, + "title": "Server Name", + "value": "${servername}" + }, + { + "short": false, + "title": "Information", + "value": "${alertmessage}" + }, + { + "short": false, "title": "Game", "value": "${gamename}" }, { - "short": true, + "short": false, "title": "Server IP", "value": "${alertip}:${port}" }, { - "short": true, + "short": false, "title": "Hostname", "value": "${HOSTNAME}" } diff --git a/lgsm/modules/command_start.sh b/lgsm/modules/command_start.sh index 364733ea2..7ec49aef5 100644 --- a/lgsm/modules/command_start.sh +++ b/lgsm/modules/command_start.sh @@ -176,6 +176,13 @@ fn_start_tmux() { fn_print_ok "${servername}" fn_script_log_pass "Started ${servername}" + if [ "${firstcommandname}" == "START" ]; then + alert="started" + alert.sh + elif [ "${firstcommandname}" == "RESTART" ]; then + alert="restarted" + alert.sh + fi fi rm -f "${lgsmlogdir:?}/.${selfname}-tmux-error.tmp" 2> /dev/null echo -en "\n" diff --git a/lgsm/modules/command_stop.sh b/lgsm/modules/command_stop.sh index 1567252f9..da4788ddc 100644 --- a/lgsm/modules/command_stop.sh +++ b/lgsm/modules/command_stop.sh @@ -51,6 +51,9 @@ fn_stop_graceful_cmd() { fn_print_ok "Graceful: sending \"${1}\": ${seconds}: " fn_print_ok_eol_nl fn_script_log_pass "Graceful: sending \"${1}\": OK: ${seconds} seconds" + if [ "${firstcommandname}" == "STOP" ]; then + alert="stopped" + fi break fi fn_sleep_time_1 @@ -80,6 +83,9 @@ fn_stop_graceful_goldsrc() { fn_print_ok "Graceful: sending \"quit\": ${seconds}: " fn_print_ok_eol_nl fn_script_log_pass "Graceful: sending \"quit\": OK: ${seconds} seconds" + if [ "${firstcommandname}" == "STOP" ]; then + alert="stopped" + fi } # telnet command for sdtd graceful shutdown. @@ -152,6 +158,10 @@ fn_stop_graceful_sdtd() { fn_print_ok "Graceful: telnet: ${telnetip}:${telnetport} : " fn_print_ok_eol_nl fn_script_log_pass "Graceful: telnet: ${telnetip}:${telnetport} : ${seconds} seconds" + if [ "${firstcommandname}" == "STOP" ]; then + alert="stopped" + alert.sh + fi break fi fn_sleep_time_1 @@ -195,6 +205,9 @@ fn_stop_graceful_avorion() { fn_print_ok "Graceful: /save /stop: ${seconds}: " fn_print_ok_eol_nl fn_script_log_pass "Graceful: /save /stop: OK: ${seconds} seconds" + if [ "${firstcommandname}" == "STOP" ]; then + alert="stopped" + fi break fi fn_sleep_time_1 @@ -246,6 +259,9 @@ fn_stop_tmux() { if [ "${status}" == "0" ]; then fn_print_ok_nl "${servername}" fn_script_log_pass "Stopped ${servername}" + if [ "${firstcommandname}" == "STOP" ]; then + alert="stopped" + fi else fn_print_fail_nl "Unable to stop ${servername}" fn_script_log_fail "Unable to stop ${servername}" diff --git a/lgsm/modules/command_wipe.sh b/lgsm/modules/command_wipe.sh index d20bd0d3e..378dae0ec 100644 --- a/lgsm/modules/command_wipe.sh +++ b/lgsm/modules/command_wipe.sh @@ -167,6 +167,8 @@ if [ -n "$(find "${serveridentitydir}" -type f -name "*.map")" ] || [ -n "$(find fn_wipe_random_seed fn_print_complete_nl "${wipetype}" fn_script_log_pass "${wipetype}" + alert="wipe" + alert.sh exitbypass=1 command_start.sh fn_firstcommand_reset @@ -175,6 +177,8 @@ if [ -n "$(find "${serveridentitydir}" -type f -name "*.map")" ] || [ -n "$(find fn_wipe_random_seed fn_print_complete_nl "${wipetype}" fn_script_log_pass "${wipetype}" + alert="wipe" + alert.sh fi else fn_print_ok_nl "Wipe not required"