8
8
moduleselfname=" $( basename " $( readlink -f " ${BASH_SOURCE[0]} " ) " ) "
9
9
10
10
# ## Define all commands here.
11
- # # User commands | Trigger commands | Description
11
+ # # User commands | Option | Trigger commands | Description
12
12
# Standard commands.
13
- cmd_install=(" i;install" " command_install.sh" " Install the server." )
14
- cmd_auto_install=(" ai;auto-install" " fn_autoinstall" " Install the server without prompts." )
15
- cmd_start=(" st;start" " command_start.sh" " Start the server." )
16
- cmd_stop=(" sp;stop" " command_stop.sh" " Stop the server." )
17
- cmd_restart=(" r;restart" " command_restart.sh" " Restart the server." )
18
- cmd_details=(" dt;details" " command_details.sh" " Display server information." )
19
- cmd_postdetails=(" pd;postdetails" " command_postdetails.sh" " Post details to termbin.com (removing passwords)." )
20
- cmd_backup=(" b;backup" " command_backup.sh" " Create backup archives of the server." )
21
- cmd_update_linuxgsm=(" ul;update-lgsm;uf;update-modules" " command_update_linuxgsm.sh" " Check and apply any LinuxGSM updates." )
22
- cmd_test_alert=(" ta;test-alert" " command_test_alert.sh" " Send a test alert." )
23
- cmd_monitor=(" m;monitor" " command_monitor.sh" " Check server status and restart if crashed." )
24
- cmd_skeleton=(" sk;skeleton" " command_skeleton.sh" " Create a skeleton directory." )
25
- cmd_sponsor=(" s;sponsor" " command_sponsor.sh" " Donation options." )
26
- cmd_send=(" sd;send" " command_send.sh" " Send command to game server console." )
13
+ cmd_install=(" i;install" " install " " command_install.sh" " Install the server." )
14
+ cmd_auto_install=(" ai;auto-install" " auto-install " " fn_autoinstall" " Install the server without prompts." )
15
+ cmd_start=(" st;start" " start " " command_start.sh" " Start the server." )
16
+ cmd_stop=(" sp;stop" " stop " " command_stop.sh" " Stop the server." )
17
+ cmd_restart=(" r;restart" " restart " " command_restart.sh" " Restart the server." )
18
+ cmd_details=(" dt;details" " details " " command_details.sh" " Display server information." )
19
+ cmd_postdetails=(" pd;postdetails" " postdetails " " command_postdetails.sh" " Post details to termbin.com (removing passwords)." )
20
+ cmd_backup=(" b;backup" " backup " " command_backup.sh" " Create backup archives of the server." )
21
+ cmd_update_linuxgsm=(" ul;update-lgsm;uf;update-modules" " update-lgsm " " command_update_linuxgsm.sh" " Check and apply any LinuxGSM updates." )
22
+ cmd_test_alert=(" ta;test-alert" " test-alert " " command_test_alert.sh" " Send a test alert." )
23
+ cmd_monitor=(" m;monitor" " monitor " " command_monitor.sh" " Check server status and restart if crashed." )
24
+ cmd_skeleton=(" sk;skeleton" " skeleton " " command_skeleton.sh" " Create a skeleton directory." )
25
+ cmd_sponsor=(" s;sponsor" " sponsor " " command_sponsor.sh" " Donation options." )
26
+ cmd_send=(" sd;send" " send " " command_send.sh" " Send command to game server console." )
27
27
# Console servers only.
28
- cmd_console=(" c;console" " command_console.sh" " Access server console." )
29
- cmd_debug=(" d;debug" " command_debug.sh" " Start server directly in your terminal." )
28
+ cmd_console=(" c;console" " console " " command_console.sh" " Access server console." )
29
+ cmd_debug=(" d;debug" " debug " " command_debug.sh" " Start server directly in your terminal." )
30
30
# Update servers only.
31
- cmd_update=(" u;update" " command_update.sh" " Check and apply any server updates." )
32
- cmd_check_update=(" cu;check-update" " command_check_update.sh" " Check if a gameserver update is available" )
33
- cmd_force_update=(" fu;force-update;update-restart;ur" " forceupdate=1; command_update.sh" " Apply server updates bypassing check." )
31
+ cmd_update=(" u;update" " update " " command_update.sh" " Check and apply any server updates." )
32
+ cmd_check_update=(" cu;check-update" " check-update " " command_check_update.sh" " Check if a gameserver update is available" )
33
+ cmd_force_update=(" fu;force-update;update-restart;ur" " force-update " " forceupdate=1; command_update.sh" " Apply server updates bypassing check." )
34
34
# SteamCMD servers only.
35
- cmd_validate=(" v;validate" " command_validate.sh" " Validate server files with SteamCMD." )
35
+ cmd_validate=(" v;validate" " validate " " command_validate.sh" " Validate server files with SteamCMD." )
36
36
# Server with mods-install.
37
- cmd_mods_install=(" mi;mods-install" " command_mods_install.sh" " View and install available mods/addons." )
38
- cmd_mods_remove=(" mr;mods-remove" " command_mods_remove.sh" " View and remove an installed mod/addon." )
39
- cmd_mods_update=(" mu;mods-update" " command_mods_update.sh" " Update installed mods/addons." )
37
+ cmd_mods_install=(" mi;mods-install" " mods-install " " command_mods_install.sh" " View and install available mods/addons." )
38
+ cmd_mods_remove=(" mr;mods-remove" " mods-remove " " command_mods_remove.sh" " View and remove an installed mod/addon." )
39
+ cmd_mods_update=(" mu;mods-update" " mods-update " " command_mods_update.sh" " Update installed mods/addons." )
40
40
# Server specific.
41
- cmd_change_password=(" pw;change-password" " command_ts3_server_pass.sh" " Change TS3 serveradmin password." )
42
- cmd_install_default_resources=(" ir;install-default-resources" " command_install_resources_mta.sh" " Install the MTA default resources." )
43
- cmd_fullwipe=(" fw;full-wipe;wa;wipeall" " serverwipe=1; command_wipe.sh" " Reset the map and remove blueprint data." )
44
- cmd_mapwipe=(" mw;map-wipe;w;wipe;wi" " mapwipe=1; command_wipe.sh" " Reset the map and keep blueprint data." )
45
- cmd_map_compressor_u99=(" mc;map-compressor" " compress_ut99_maps.sh" " Compresses all ${gamename} server maps." )
46
- cmd_map_compressor_u2=(" mc;map-compressor" " compress_unreal2_maps.sh" " Compresses all ${gamename} server maps." )
47
- cmd_install_cdkey=(" cd;server-cd-key" " install_ut2k4_key.sh" " Add your server cd key." )
48
- cmd_install_dst_token=(" ct;cluster-token" " install_dst_token.sh" " Configure cluster token." )
49
- cmd_install_squad_license=(" li;license" " install_squad_license.sh" " Add your Squad server license." )
50
- cmd_fastdl=(" fd;fastdl" " command_fastdl.sh" " Build a FastDL directory." )
41
+ cmd_change_password=(" pw;change-password" " change-password " " command_ts3_server_pass.sh" " Change TS3 serveradmin password." )
42
+ cmd_install_default_resources=(" ir;install-default-resources" " install-default-resources " " command_install_resources_mta.sh" " Install the MTA default resources." )
43
+ cmd_fullwipe=(" fw;full-wipe;wa;wipeall" " full-wipe " " serverwipe=1; command_wipe.sh" " Reset the map and remove blueprint data." )
44
+ cmd_mapwipe=(" mw;map-wipe;w;wipe;wi" " map-wipe " " mapwipe=1; command_wipe.sh" " Reset the map and keep blueprint data." )
45
+ cmd_map_compressor_u99=(" mc;map-compressor" " map-compressor " " compress_ut99_maps.sh" " Compresses all ${gamename} server maps." )
46
+ cmd_map_compressor_u2=(" mc;map-compressor" " map-compressor " " compress_unreal2_maps.sh" " Compresses all ${gamename} server maps." )
47
+ cmd_install_cdkey=(" cd;server-cd-key" " server-cd-key " " install_ut2k4_key.sh" " Add your server cd key." )
48
+ cmd_install_dst_token=(" ct;cluster-token" " cluster-token " " install_dst_token.sh" " Configure cluster token." )
49
+ cmd_install_squad_license=(" li;license" " license " " install_squad_license.sh" " Add your Squad server license." )
50
+ cmd_fastdl=(" fd;fastdl" " fastdl " " command_fastdl.sh" " Build a FastDL directory." )
51
51
# Dev commands.
52
- cmd_dev_debug=(" dev;developer" " command_dev_debug.sh" " Enable developer Mode." )
53
- cmd_dev_details=(" ddt;detect-details" " command_dev_details.sh" " Display parsed details." )
54
- cmd_dev_detect_deps=(" dd;detect-deps" " command_dev_detect_deps.sh" " Detect required dependencies." )
55
- cmd_dev_detect_glibc=(" dg;detect-glibc" " command_dev_detect_glibc.sh" " Detect required glibc." )
56
- cmd_dev_detect_ldd=(" dl;detect-ldd" " command_dev_detect_ldd.sh" " Detect required dynamic dependencies." )
57
- cmd_dev_query_raw=(" qr;query-raw" " command_dev_query_raw.sh" " The raw output of gamedig and gsquery." )
58
- cmd_dev_clear_modules=(" cm;clear-modules" " command_dev_clear_modules.sh" " Delete the contents of the modules dir." )
59
-
52
+ cmd_dev_debug=(" dev;developer" " developer" " command_dev_debug.sh" " Enable developer Mode." )
53
+ cmd_dev_details=(" ddt;detect-details" " detect-details" " command_dev_details.sh" " Display parsed details." )
54
+ cmd_dev_detect_deps=(" dd;detect-deps" " detect-deps" " command_dev_detect_deps.sh" " Detect required dependencies." )
55
+ cmd_dev_detect_glibc=(" dg;detect-glibc" " detect-glibc" " command_dev_detect_glibc.sh" " Detect required glibc." )
56
+ cmd_dev_detect_ldd=(" dl;detect-ldd" " detect-ldd" " command_dev_detect_ldd.sh" " Detect required dynamic dependencies." )
57
+ cmd_dev_query_raw=(" qr;query-raw" " query-raw" " command_dev_query_raw.sh" " The raw output of gamedig and gsquery." )
58
+ cmd_dev_clear_modules=(" cm;clear-modules" " clear-modules" " command_dev_clear_modules.sh" " Delete the contents of the modules dir." )
60
59
# ## Set specific opt here.
61
60
62
61
currentopt=(" ${cmd_start[@]} " " ${cmd_stop[@]} " " ${cmd_restart[@]} " " ${cmd_monitor[@]} " " ${cmd_test_alert[@]} " " ${cmd_details[@]} " " ${cmd_postdetails[@]} " " ${cmd_skeleton[@]} " )
@@ -155,7 +154,7 @@ currentopt+=("${cmd_sponsor[@]}")
155
154
# ## Build list of available commands.
156
155
optcommands=()
157
156
index=" 0"
158
- for (( index = "0 "; index < ${# currentopt[@]} ; index += 3 )) ; do
157
+ for (( index = "0 "; index < ${# currentopt[@]} ; index += 4 )) ; do
159
158
cmdamount=$( echo -e " ${currentopt[index]} " | awk -F ' ;' ' { print NF }' )
160
159
for (( cmdindex = 1 ; cmdindex <= cmdamount; cmdindex++ )) ; do
161
160
optcommands+=(" $( echo -e " ${currentopt[index]} " | awk -F ' ;' -v x=${cmdindex} ' { print $x }' ) " )
@@ -175,8 +174,8 @@ fn_opt_usage() {
175
174
{
176
175
for (( index = "0 "; index < ${# currentopt[@]} ; index += 3 )) ; do
177
176
# Hide developer commands.
178
- if [ " ${currentopt[index + 2 ]} " != " DEVCOMMAND" ]; then
179
- echo -e " ${cyan} $( echo -e " ${currentopt[index]} " | awk -F ' ;' ' { print $2 }' ) \t${default} $( echo -e " ${currentopt[index]} " | awk -F ' ;' ' { print $1 }' ) \t| ${currentopt[index + 2 ]} "
177
+ if [ " ${currentopt[index + 3 ]} " != " DEVCOMMAND" ]; then
178
+ echo -e " ${cyan} $( echo -e " ${currentopt[index]} " | awk -F ' ;' ' { print $2 }' ) \t${default} $( echo -e " ${currentopt[index]} " | awk -F ' ;' ' { print $1 }' ) \t| ${currentopt[index + 3 ]} "
180
179
fi
181
180
done
182
181
} | column -s $' \t ' -t
@@ -193,12 +192,17 @@ for i in "${optcommands[@]}"; do
193
192
if [ " ${i} " == " ${getopt} " ]; then
194
193
# Seek and run command.
195
194
index=" 0"
196
- for (( index = "0 "; index < ${# currentopt[@]} ; index += 3 )) ; do
195
+ for (( index = "0 "; index < ${# currentopt[@]} ; index += 4 )) ; do
197
196
currcmdamount=$( echo -e " ${currentopt[index]} " | awk -F ' ;' ' { print NF }' )
198
197
for (( currcmdindex = 1 ; currcmdindex <= currcmdamount; currcmdindex++ )) ; do
199
198
if [ " $( echo -e " ${currentopt[index]} " | awk -F ' ;' -v x=${currcmdindex} ' { print $x }' ) " == " ${getopt} " ]; then
199
+ # run pre hook
200
+ hookoption=" ${currentopt[index + 1]} "
201
+ if [ -f " ${hooksdir} /hook-pre-${hookoption} .sh" ]; then
202
+ eval " ${hooksdir} /hook-pre-${hookoption} .sh"
203
+ fi
200
204
# Run command.
201
- eval " ${currentopt[index + 1 ]} "
205
+ eval " ${currentopt[index + 2 ]} "
202
206
# Exit should occur in modules. Should this not happen print an error
203
207
fn_print_error2_nl " Command did not exit correctly: ${getopt} "
204
208
fn_script_log_error " Command did not exit correctly: ${getopt} "
0 commit comments