From 1b9e0bcd1b13cbb12aca510a0ddd50062b76c637 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Fri, 13 Jan 2017 03:12:01 +0100 Subject: [PATCH] Fixes #1235 and more No config alteration for Ark, and requires to create the cfgdir. + Rearranging presentation to make more visual sense --- lgsm/functions/install_config.sh | 73 +++++++++++++++++--------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index 10a7040d2..426bec9c8 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -8,35 +8,7 @@ local commandname="INSTALL" local commandaction="Install" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -fn_fetch_default_config(){ - mkdir -pv "${lgsmdir}/default-configs" - githuburl="https://github.com/GameServerManagers/Game-Server-Configs/master" - - for config in "${array_configs[@]}" - do - fileurl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/master/${gamedirname}/${config}"; filedir="${lgsmdir}/default-configs"; filename="${config}"; executecmd="noexecute" run="norun"; force="noforce" - fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" - done -} - -# Changes some variables within the default configs -# SERVERNAME to LinuxGSM -# PASSWORD to random password -fn_set_config_vars(){ - random=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 8 | tr -d '\n'; echo) - servername="LinuxGSM" - rconpass="admin$random" - echo "changing hostname." - fn_script_log_info "changing hostname." - sleep 1 - sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}" - echo "changing rcon/admin password." - fn_script_log_info "changing rcon/admin password." - sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}" - sleep 1 -} - -# Checks if cfg dir exists, creates it if it doesn't +# Checks if server cfg dir exists, creates it if it doesn't fn_check_cfgdir(){ if [ ! -d "${servercfgdir}" ]; then echo "creating ${servercfgdir} config directory." @@ -45,11 +17,19 @@ fn_check_cfgdir(){ fi } -# Copys the default configs from Game-Server-Configs repo to the -# correct location +# Downloads default configs from Game-Server-Configs repo to lgsm/default-configs +fn_fetch_default_config(){ + mkdir -pv "${lgsmdir}/default-configs" + githuburl="https://github.com/GameServerManagers/Game-Server-Configs/master" + for config in "${array_configs[@]}"; do + fileurl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/master/${gamedirname}/${config}"; filedir="${lgsmdir}/default-configs"; filename="${config}"; executecmd="noexecute" run="norun"; force="noforce" + fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" + done +} + +# Copys default configs from Game-Server-Configs repo to server config location fn_default_config_remote(){ - for config in "${array_configs[@]}" - do + for config in "${array_configs[@]}"; do # every config is copied echo "copying ${config} config file." fn_script_log_info "copying ${servercfg} config file." @@ -66,6 +46,29 @@ fn_default_config_remote(){ sleep 1 } +# Changes some variables within the default configs +# SERVERNAME to LinuxGSM +# PASSWORD to random password +fn_set_config_vars(){ + if [ -f "${servercfgfullpath}" ]; then + random=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 8 | tr -d '\n'; echo) + servername="LinuxGSM" + rconpass="admin$random" + echo "changing hostname." + fn_script_log_info "changing hostname." + sleep 1 + sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}" + echo "changing rcon/admin password." + fn_script_log_info "changing rcon/admin password." + sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}" + sleep 1 + else + fn_script_log_warn "Config file not found, cannot alter it." + echo "Config file not found, cannot alter it." + sleep 1 + fi +} + # Changes some variables within the default Don't Starve Together configs fn_set_dst_config_vars(){ ## cluster.ini @@ -129,10 +132,10 @@ if [ "${gamename}" == "7 Days To Die" ]; then fn_set_config_vars elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then gamedirname="ARKSurvivalEvolved" + fn_check_cfgdir array_configs+=( GameUserSettings.ini ) fn_fetch_default_config fn_default_config_remote - fn_set_config_vars elif [ "${gamename}" == "ARMA 3" ]; then gamedirname="Arma3" fn_check_cfgdir @@ -494,4 +497,4 @@ elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then fn_fetch_default_config fn_default_config_remote fn_set_config_vars -fi \ No newline at end of file +fi