File tree Expand file tree Collapse file tree 5 files changed +56
-1
lines changed Expand file tree Collapse file tree 5 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,17 @@ fn_alert_log() {
2727 } | sed -r " s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | tee -a " ${alertlog} " > /dev/null 2>&1
2828}
2929
30+ fn_alert_custom () {
31+ fn_script_log_info " Sending custom alert: Custom alert from ${selfname} ."
32+ alertaction=" ${customalerttitle} "
33+ alertemoji=" 📢"
34+ alertsound=" 1"
35+ alertmessage=" ${customalertmessage} "
36+ # Green
37+ alertcolourhex=" #6600CC"
38+ alertcolourdec=" 6684876"
39+ }
40+
3041fn_alert_test () {
3142 fn_script_log_info " Sending alert: Testing LinuxGSM Alert. No action to be taken"
3243 alertaction=" Tested"
@@ -206,6 +217,8 @@ elif [ "${alert}" == "monitor-session" ]; then
206217 fn_alert_monitor_session
207218elif [ " ${alert} " == " monitor-query" ]; then
208219 fn_alert_monitor_query
220+ elif [ " ${alert} " == " custom" ]; then
221+ fn_alert_custom
209222elif [ " ${alert} " == " test" ]; then
210223 fn_alert_test
211224elif [ " ${alert} " == " update" ]; then
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # LinuxGSM command_custom_alert.sh module
3+ # Author: Daniel Gibbs
4+ # Contributors: http://linuxgsm.com/contrib
5+ # Website: https://linuxgsm.com
6+ # Description: Sends a custom alert.
7+
8+ commandname=" CUSTOM-ALERT"
9+ commandaction=" Custom Alert"
10+ moduleselfname=" $( basename " $( readlink -f " ${BASH_SOURCE[0]} " ) " ) "
11+ fn_firstcommand_set
12+
13+ check.sh
14+
15+ if [ -n " ${userinput2} " ]; then
16+ customalertmessage=" ${userinput2} "
17+ else
18+ fn_print_header
19+ fn_print_information_nl " Send a custom alert."
20+ echo " "
21+ customalertmessage=$( fn_prompt_message " alert message: " )
22+ fi
23+
24+ # optional: custom alert title
25+ if [ -n " ${userinput3} " ]; then
26+ customalerttitle=" ${userinput3} "
27+ else
28+ customalerttitle=" Custom Alert"
29+ fi
30+
31+ info_game.sh
32+ alert=" custom"
33+ alert.sh
34+
35+ core_exit.sh
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ cmd_details=("dt;details" "command_details.sh" "Display server information.")
1919cmd_postdetails=(" pd;postdetails" " command_postdetails.sh" " Post details to termbin.com (removing passwords)." )
2020cmd_backup=(" b;backup" " command_backup.sh" " Create backup archives of the server." )
2121cmd_update_linuxgsm=(" ul;update-lgsm;uf;update-modules" " command_update_linuxgsm.sh" " Check and apply any LinuxGSM updates." )
22+ cmd_custom_alert=(" ca;custom-alert" " command_custom_alert.sh" " Send a customizable alert." )
2223cmd_test_alert=(" ta;test-alert" " command_test_alert.sh" " Send a test alert." )
2324cmd_monitor=(" m;monitor" " command_monitor.sh" " Check server status and restart if crashed." )
2425cmd_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
6061
6162# ## Set specific opt here.
6263
63- currentopt=(" ${cmd_start[@]} " " ${cmd_stop[@]} " " ${cmd_restart[@]} " " ${cmd_monitor[@]} " " ${cmd_test_alert[@]} " " ${cmd_details[@]} " " ${cmd_postdetails[@]} " " ${cmd_skeleton[@]} " )
64+ currentopt=(" ${cmd_start[@]} " " ${cmd_stop[@]} " " ${cmd_restart[@]} " " ${cmd_monitor[@]} " " ${cmd_custom_alert[@]} " " ${ cmd_test_alert[@]}" " ${cmd_details[@]} " " ${cmd_postdetails[@]} " " ${cmd_skeleton[@]} " )
6465
6566# Update LinuxGSM.
6667currentopt+=(" ${cmd_update_linuxgsm[@]} " )
Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ command_postdetails.sh() {
9696 fn_fetch_module
9797}
9898
99+ command_custom_alert.sh () {
100+ modulefile=" ${FUNCNAME[0]} "
101+ fn_fetch_module
102+ }
103+
99104command_test_alert.sh () {
100105 modulefile=" ${FUNCNAME[0]} "
101106 fn_fetch_module
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ configdirserver="${configdir}/${gameservername}"
4848configdirdefault=" ${lgsmdir} /config-default"
4949userinput=" ${1} "
5050userinput2=" ${2} "
51+ userinput3=" ${3} "
5152
5253# # GitHub Branch Select
5354# Allows for the use of different function files
You can’t perform that action at this time.
0 commit comments