diff --git a/CounterStrikeGlobalOffensive/csgoserver b/CounterStrikeGlobalOffensive/csgoserver index 1a06e28bf..1af1b727f 100755 --- a/CounterStrikeGlobalOffensive/csgoserver +++ b/CounterStrikeGlobalOffensive/csgoserver @@ -155,7 +155,4 @@ functionfile="${FUNCNAME}" fn_runfunction } -fn_functions - -getopt=$1 -fn_getopt +core_functions.sh \ No newline at end of file diff --git a/functions/check.sh b/functions/check.sh new file mode 100644 index 000000000..db143a978 --- /dev/null +++ b/functions/check.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# LGSM fn_check function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +lgsm_version="201215" + +# Description: Overall function for managing checks. +# Runs checks that will either halt on or fix an issue. + +fn_module_compare() { + local e + for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done + return 1 +} + + +check_root.sh + +if [ "${module}" != "install" ]; then + check_executable.sh +fi + +no_check_logs=( details install map-compressor) +fn_module_compare "${module}" "${no_check_logs[@]}" +if [ $? != 0 ]; then + fn_check_logs +fi + + +fn_check_ip +fn_check_steamcmd +fn_check_steamuser +fn_check_tmux + +fn_check_ts3status # may need to move out of checks \ No newline at end of file diff --git a/functions/fn_check_ip b/functions/check_ip.sh similarity index 100% rename from functions/fn_check_ip rename to functions/check_ip.sh diff --git a/functions/fn_check_logs b/functions/check_logs.sh similarity index 100% rename from functions/fn_check_logs rename to functions/check_logs.sh diff --git a/functions/fn_check_root b/functions/check_root.sh similarity index 86% rename from functions/fn_check_root rename to functions/check_root.sh index 16f253e35..3275d2261 100644 --- a/functions/fn_check_root +++ b/functions/check_root.sh @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM fn_check_root function +# LGSM check_root.sh function # Author: Daniel Gibbs # Website: http://gameservermanagers.com lgsm_version="061115" diff --git a/functions/fn_check_steamcmd b/functions/check_steamcmd.sh similarity index 100% rename from functions/fn_check_steamcmd rename to functions/check_steamcmd.sh diff --git a/functions/fn_check_steamuser b/functions/check_steamuser.sh similarity index 100% rename from functions/fn_check_steamuser rename to functions/check_steamuser.sh diff --git a/functions/fn_check_systemdir b/functions/check_systemdir.sh similarity index 86% rename from functions/fn_check_systemdir rename to functions/check_systemdir.sh index fba1566f0..ffd92253a 100644 --- a/functions/fn_check_systemdir +++ b/functions/check_systemdir.sh @@ -4,7 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="061115" -if [ ! -e "${systemdir}" ]; then +if [ ! -f "${systemdir}" ]; then fn_printfailnl "Cannot access ${systemdir}: No such directory" exit 1 fi diff --git a/functions/fn_check_tmux b/functions/check_tmux.sh similarity index 100% rename from functions/fn_check_tmux rename to functions/check_tmux.sh diff --git a/functions/fn_backup b/functions/command_backup.sh similarity index 99% rename from functions/fn_backup rename to functions/command_backup.sh index 33b946d1a..8790767ac 100644 --- a/functions/fn_backup +++ b/functions/command_backup.sh @@ -7,7 +7,7 @@ lgsm_version="201215" # Description: Creates a .tar.gz file in the backup directory. local modulename="Backup" -fn_check_root +check_root.sh fn_check_systemdir backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" echo "" diff --git a/functions/fn_console b/functions/command_console.sh similarity index 98% rename from functions/fn_console rename to functions/command_console.sh index 992c9bd1a..991499a2f 100644 --- a/functions/fn_console +++ b/functions/command_console.sh @@ -7,7 +7,7 @@ lgsm_version="061115" # Description: Gives access to the server tmux console. local modulename="Console" -fn_check_root +check_root.sh fn_check_systemdir echo "" echo "${gamename} Console" diff --git a/functions/fn_debug b/functions/command_debug similarity index 99% rename from functions/fn_debug rename to functions/command_debug index cb4067943..39399f52c 100644 --- a/functions/fn_debug +++ b/functions/command_debug @@ -7,7 +7,7 @@ lgsm_version="061115" # Description: Runs the server without tmux. Runs direct from the terminal. local modulename="Debug" -fn_check_root +check_root.sh fn_check_systemdir fn_check_ip fn_check_logs diff --git a/functions/command_debug.sh b/functions/command_debug.sh new file mode 100644 index 000000000..39399f52c --- /dev/null +++ b/functions/command_debug.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# LGSM fn_debug function +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +lgsm_version="061115" + +# Description: Runs the server without tmux. Runs direct from the terminal. + +local modulename="Debug" +check_root.sh +fn_check_systemdir +fn_check_ip +fn_check_logs +fn_details_distro +fn_parms +echo "" +echo "${gamename} Debug" +echo "============================" +echo "" +echo -e "Distro: ${os}" +echo -e "Arch: ${arch}" +echo -e "Kernel: ${kernel}" +echo -e "Hostname: $HOSTNAME" +echo "" +echo "Start parameters:" +if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then + echo "${executable} ${parms} -debug" +else + echo "${executable} ${parms}" +fi +echo "" +echo -e "Use for identifying server issues only!" +echo -e "Press CTRL+c to drop out of debug mode." +fn_printwarningnl "If ${servicename} is already running it will be stopped." +echo "" +while true; do + read -e -i "y" -p "Continue? [Y/n]" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) echo Exiting; return;; + * ) echo "Please answer yes or no.";; +esac +done +fn_scriptlog "Starting debug" +fn_printinfonl "Stopping any running servers" +fn_scriptlog "Stopping any running servers" +sleep 1 +fn_stop +fn_printdots "Starting debug" +sleep 1 +fn_printok "Starting debug" +fn_scriptlog "Started debug" +sleep 1 +echo -en "\n" +cd "${executabledir}" +if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then + if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then + startfix=1 + fn_csgofix + elif [ "${gamename}" == "Insurgency" ]; then + fn_insfix + elif [ "${gamename}" == "ARMA 3" ]; then + fn_arma3fix + fi + ${executable} ${parms} -debug +else + ${executable} ${parms} +fi \ No newline at end of file diff --git a/functions/fn_details b/functions/command_details.sh similarity index 100% rename from functions/fn_details rename to functions/command_details.sh diff --git a/functions/fn_install b/functions/command_install.sh similarity index 97% rename from functions/fn_install rename to functions/command_install.sh index 0cc9129c4..5cba3b51b 100644 --- a/functions/fn_install +++ b/functions/command_install.sh @@ -4,7 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="201215" -fn_check_root +check_root.sh fn_install_header fn_install_serverdir diff --git a/functions/fn_monitor b/functions/command_monitor.sh similarity index 99% rename from functions/fn_monitor rename to functions/command_monitor.sh index 02380440e..6ea75a020 100644 --- a/functions/fn_monitor +++ b/functions/command_monitor.sh @@ -10,7 +10,7 @@ lgsm_version="061115" local modulename="Monitor" fn_monitor_teamspeak3(){ -fn_check_root +check_root.sh fn_check_systemdir fn_logs fn_printdots "${servername}" @@ -54,7 +54,7 @@ fn_restart } fn_monitor_tmux(){ -fn_check_root +check_root.sh fn_check_systemdir fn_check_ip fn_details_config diff --git a/functions/fn_start b/functions/command_start.sh similarity index 99% rename from functions/fn_start rename to functions/command_start.sh index 742c76b60..96193e286 100644 --- a/functions/fn_start +++ b/functions/command_start.sh @@ -9,7 +9,7 @@ lgsm_version="201215" local modulename="Starting" fn_start_teamspeak3(){ -fn_check_root +check_root.sh fn_check_systemdir fn_check_logs fn_check_ts3status @@ -73,7 +73,7 @@ echo -en "\n" } fn_start_tmux(){ -fn_check_root +check_root.sh fn_check_systemdir fn_check_ip fn_check_logs diff --git a/functions/fn_stop b/functions/command_stop.sh similarity index 99% rename from functions/fn_stop rename to functions/command_stop.sh index 35244f1fd..68b2d002e 100644 --- a/functions/fn_stop +++ b/functions/command_stop.sh @@ -29,7 +29,7 @@ sdtd_telnet(){ } fn_stop_teamspeak3(){ -fn_check_root +check_root.sh fn_check_systemdir fn_printdots "${servername}" fn_scriptlog "${servername}" @@ -50,7 +50,7 @@ echo -en "\n" } fn_stop_tmux(){ -fn_check_root +check_root.sh fn_check_systemdir fn_details_config fn_printdots "${servername}" diff --git a/functions/command_update.sh b/functions/command_update.sh new file mode 100644 index 000000000..e69de29bb diff --git a/functions/fn_validate b/functions/command_validate.sh similarity index 100% rename from functions/fn_validate rename to functions/command_validate.sh diff --git a/functions/fn_compress_unreal2maps b/functions/compress_unreal2_maps.sh similarity index 98% rename from functions/fn_compress_unreal2maps rename to functions/compress_unreal2_maps.sh index fec5d113f..aa9c5d0ad 100644 --- a/functions/fn_compress_unreal2maps +++ b/functions/compress_unreal2_maps.sh @@ -4,7 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="061115" -fn_check_root +check_root.sh clear echo "${gamename} Map Compressor" echo "============================" diff --git a/functions/fn_compress_ut99maps b/functions/compress_ut99_maps.sh similarity index 98% rename from functions/fn_compress_ut99maps rename to functions/compress_ut99_maps.sh index f9e0c9433..b5a1a04d0 100644 --- a/functions/fn_compress_ut99maps +++ b/functions/compress_ut99_maps.sh @@ -4,7 +4,7 @@ # Website: http://gameservermanagers.com lgsm_version="061115" -fn_check_root +check_root.sh clear echo "${gamename} Map Compressor" echo "============================" diff --git a/functions/fn_functions b/functions/core_functions.sh similarity index 99% rename from functions/fn_functions rename to functions/core_functions.sh index 39e3220d6..c684c97af 100644 --- a/functions/fn_functions +++ b/functions/core_functions.sh @@ -27,7 +27,7 @@ functionfile="${FUNCNAME}" fn_runfunction } -fn_check_root(){ +check_root.sh(){ functionfile="${FUNCNAME}" fn_runfunction } diff --git a/functions/fn_getopt b/functions/core_getopt.sh similarity index 100% rename from functions/fn_getopt rename to functions/core_getopt.sh diff --git a/functions/fn_messages b/functions/core_messages.sh similarity index 99% rename from functions/fn_messages rename to functions/core_messages.sh index a8d55cb5b..c33e466d0 100644 --- a/functions/fn_messages +++ b/functions/core_messages.sh @@ -145,4 +145,7 @@ fn_printokeol(){ # FAIL for end of line fn_printfaileol(){ echo -e "\e[0;31mFAIL\e[0m\n" -} \ No newline at end of file +} + +getopt=$1 +core_getopt.sh \ No newline at end of file diff --git a/functions/fn_debug_dev b/functions/dev_debug.sh similarity index 100% rename from functions/fn_debug_dev rename to functions/dev_debug.sh diff --git a/functions/fn_deps_detect b/functions/dev_detect_deps.sh similarity index 99% rename from functions/fn_deps_detect rename to functions/dev_detect_deps.sh index 93e11094b..bd17b97b8 100644 --- a/functions/fn_deps_detect +++ b/functions/dev_detect_deps.sh @@ -7,7 +7,7 @@ lgsm_version="201215" # Description: Detects dependencies the server binary requires. local modulename="Backup" -fn_check_root +check_root.sh fn_check_systemdir cd "${executabledir}" if [ "${executable}" == "./hlds_run" ]; then diff --git a/functions/fn_email b/functions/email.sh similarity index 100% rename from functions/fn_email rename to functions/email.sh diff --git a/functions/fn_email_test b/functions/email_test.sh similarity index 97% rename from functions/fn_email_test rename to functions/email_test.sh index f46924d53..226c980f5 100644 --- a/functions/fn_email_test +++ b/functions/email_test.sh @@ -7,7 +7,7 @@ lgsm_version="061115" # Description: Sends a test email notification. local modulename="Email" -fn_check_root +check_root.sh fn_check_systemdir fn_details_config if [ "${emailnotification}" = "on" ]; then diff --git a/functions/fn_arma3fix b/functions/fix_arma3.sh similarity index 100% rename from functions/fn_arma3fix rename to functions/fix_arma3.sh diff --git a/functions/fn_csgofix b/functions/fix_csgo.sh similarity index 100% rename from functions/fn_csgofix rename to functions/fix_csgo.sh diff --git a/functions/fn_install_glibcfix b/functions/fix_glibc.sh similarity index 100% rename from functions/fn_install_glibcfix rename to functions/fix_glibc.sh diff --git a/functions/fn_insfix b/functions/fix_ins.sh similarity index 100% rename from functions/fn_insfix rename to functions/fix_ins.sh diff --git a/functions/fn_details_config b/functions/info_config.sh similarity index 100% rename from functions/fn_details_config rename to functions/info_config.sh diff --git a/functions/fn_details_distro b/functions/info_distro.sh similarity index 100% rename from functions/fn_details_distro rename to functions/info_distro.sh diff --git a/functions/fn_details_glibc b/functions/info_glibc.sh similarity index 100% rename from functions/fn_details_glibc rename to functions/info_glibc.sh diff --git a/functions/fn_check_ts3status b/functions/info_ts3status.sh similarity index 100% rename from functions/fn_check_ts3status rename to functions/info_ts3status.sh diff --git a/functions/fn_install_complete b/functions/install_complete.sh similarity index 100% rename from functions/fn_install_complete rename to functions/install_complete.sh diff --git a/functions/fn_install_config b/functions/install_config.sh similarity index 100% rename from functions/fn_install_config rename to functions/install_config.sh diff --git a/functions/fn_install_ut2k4filesdl b/functions/install_dl_ut2k4.sh similarity index 100% rename from functions/fn_install_ut2k4filesdl rename to functions/install_dl_ut2k4.sh diff --git a/functions/fn_install_ut99filesdl b/functions/install_dl_ut99.sh similarity index 100% rename from functions/fn_install_ut99filesdl rename to functions/install_dl_ut99.sh diff --git a/functions/fn_install_kffix b/functions/install_fix_kf.sh similarity index 100% rename from functions/fn_install_kffix rename to functions/install_fix_kf.sh diff --git a/functions/fn_install_rofix b/functions/install_fix_ro.sh similarity index 100% rename from functions/fn_install_rofix rename to functions/install_fix_ro.sh diff --git a/functions/fn_install_steamfix b/functions/install_fix_steam.sh similarity index 100% rename from functions/fn_install_steamfix rename to functions/install_fix_steam.sh diff --git a/functions/fn_install_ut2k4fix b/functions/install_fix_ut2k4.sh similarity index 100% rename from functions/fn_install_ut2k4fix rename to functions/install_fix_ut2k4.sh diff --git a/functions/fn_install_ut99fix b/functions/install_fix_ut99.sh similarity index 100% rename from functions/fn_install_ut99fix rename to functions/install_fix_ut99.sh diff --git a/functions/fn_install_gslt b/functions/install_gslt.sh similarity index 100% rename from functions/fn_install_gslt rename to functions/install_gslt.sh diff --git a/functions/fn_install_gsquery b/functions/install_gsquery.sh similarity index 100% rename from functions/fn_install_gsquery rename to functions/install_gsquery.sh diff --git a/functions/fn_install_header b/functions/install_header.sh similarity index 100% rename from functions/fn_install_header rename to functions/install_header.sh diff --git a/functions/fn_install_logs b/functions/install_logs.sh similarity index 100% rename from functions/fn_install_logs rename to functions/install_logs.sh diff --git a/functions/fn_install_retry b/functions/install_retry.sh similarity index 100% rename from functions/fn_install_retry rename to functions/install_retry.sh diff --git a/functions/fn_install_serverdir b/functions/install_serverdir.sh similarity index 100% rename from functions/fn_install_serverdir rename to functions/install_serverdir.sh diff --git a/functions/fn_install_serverfiles b/functions/install_serverfiles.sh similarity index 100% rename from functions/fn_install_serverfiles rename to functions/install_serverfiles.sh diff --git a/functions/fn_install_steamcmd b/functions/install_steamcmd.sh similarity index 100% rename from functions/fn_install_steamcmd rename to functions/install_steamcmd.sh diff --git a/functions/fn_install_ts3 b/functions/install_ts3 similarity index 100% rename from functions/fn_install_ts3 rename to functions/install_ts3 diff --git a/functions/fn_install_ut2k4 b/functions/install_ut2k4.sh similarity index 100% rename from functions/fn_install_ut2k4 rename to functions/install_ut2k4.sh diff --git a/functions/fn_install_ut2k4key b/functions/install_ut2k4_key.sh similarity index 100% rename from functions/fn_install_ut2k4key rename to functions/install_ut2k4_key.sh diff --git a/functions/fn_install_ut99 b/functions/install_ut99.sh similarity index 100% rename from functions/fn_install_ut99 rename to functions/install_ut99.sh diff --git a/functions/fn_logs b/functions/logs.sh similarity index 100% rename from functions/fn_logs rename to functions/logs.sh diff --git a/functions/fn_monitor_query b/functions/monitor_gsquery.sh similarity index 100% rename from functions/fn_monitor_query rename to functions/monitor_gsquery.sh diff --git a/functions/fn_update_check b/functions/update_check.sh similarity index 100% rename from functions/fn_update_check rename to functions/update_check.sh diff --git a/functions/fn_update_dl b/functions/update_dl.sh similarity index 99% rename from functions/fn_update_dl rename to functions/update_dl.sh index 835727cd0..52d72774a 100644 --- a/functions/fn_update_dl +++ b/functions/update_dl.sh @@ -9,7 +9,7 @@ lgsm_version="061115" local modulename="Update" fn_steamcmd_dl(){ -fn_check_root +check_root.sh fn_check_systemdir fn_details_config fn_printdots "Updating ${servername}" @@ -39,7 +39,7 @@ fi } fn_teamspeak3_dl(){ -fn_check_root +check_root.sh fn_check_systemdir fn_details_config fn_printdots "Updating ${servername}" diff --git a/functions/fn_update_functions b/functions/update_functions.sh similarity index 100% rename from functions/fn_update_functions rename to functions/update_functions.sh