Browse Source

Fixes #1235 and more

No config alteration for Ark, and requires to create the cfgdir. 
+ Rearranging presentation to make more visual sense
pull/1243/head
UltimateByte 8 years ago
committed by GitHub
parent
commit
1b9e0bcd1b
  1. 67
      lgsm/functions/install_config.sh

67
lgsm/functions/install_config.sh

@ -8,21 +8,49 @@ local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Checks if server cfg dir exists, creates it if it doesn't
fn_check_cfgdir(){
if [ ! -d "${servercfgdir}" ]; then
echo "creating ${servercfgdir} config directory."
fn_script_log_info "creating ${servercfgdir} config directory."
mkdir -pv "${servercfgdir}"
fi
}
# Downloads default configs from Game-Server-Configs repo to lgsm/default-configs
fn_fetch_default_config(){ fn_fetch_default_config(){
mkdir -pv "${lgsmdir}/default-configs" mkdir -pv "${lgsmdir}/default-configs"
githuburl="https://github.com/GameServerManagers/Game-Server-Configs/master" githuburl="https://github.com/GameServerManagers/Game-Server-Configs/master"
for config in "${array_configs[@]}"; do
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" 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}" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
done done
} }
# Copys default configs from Game-Server-Configs repo to server config location
fn_default_config_remote(){
for config in "${array_configs[@]}"; do
# every config is copied
echo "copying ${config} config file."
fn_script_log_info "copying ${servercfg} config file."
if [ "${config}" == "${servercfgdefault}" ]; then
cp -v "${lgsmdir}/default-configs/${config}" "${servercfgfullpath}"
elif [ "${gamename}" == "ARMA 3" ]&&[ "${config}" == "${networkcfgdefault}" ]; then
cp -v "${lgsmdir}/default-configs/${config}" "${networkcfgfullpath}"
elif [ "${gamename}" == "Don't Starve Together" ]&&[ "${config}" == "${clustercfgdefault}" ]; then
cp -nv "${lgsmdir}/default-configs/${clustercfgdefault}" "${clustercfgfullpath}"
else
cp -v "${lgsmdir}/default-configs/${config}" "${servercfgdir}/${config}"
fi
done
sleep 1
}
# Changes some variables within the default configs # Changes some variables within the default configs
# SERVERNAME to LinuxGSM # SERVERNAME to LinuxGSM
# PASSWORD to random password # PASSWORD to random password
fn_set_config_vars(){ fn_set_config_vars(){
if [ -f "${servercfgfullpath}" ]; then
random=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 8 | tr -d '\n'; echo) random=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 8 | tr -d '\n'; echo)
servername="LinuxGSM" servername="LinuxGSM"
rconpass="admin$random" rconpass="admin$random"
@ -34,36 +62,11 @@ fn_set_config_vars(){
fn_script_log_info "changing rcon/admin password." fn_script_log_info "changing rcon/admin password."
sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}" sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}"
sleep 1 sleep 1
}
# Checks if cfg dir exists, creates it if it doesn't
fn_check_cfgdir(){
if [ ! -d "${servercfgdir}" ]; then
echo "creating ${servercfgdir} config directory."
fn_script_log_info "creating ${servercfgdir} config directory."
mkdir -pv "${servercfgdir}"
fi
}
# Copys the default configs from Game-Server-Configs repo to the
# correct location
fn_default_config_remote(){
for config in "${array_configs[@]}"
do
# every config is copied
echo "copying ${config} config file."
fn_script_log_info "copying ${servercfg} config file."
if [ "${config}" == "${servercfgdefault}" ]; then
cp -v "${lgsmdir}/default-configs/${config}" "${servercfgfullpath}"
elif [ "${gamename}" == "ARMA 3" ]&&[ "${config}" == "${networkcfgdefault}" ]; then
cp -v "${lgsmdir}/default-configs/${config}" "${networkcfgfullpath}"
elif [ "${gamename}" == "Don't Starve Together" ]&&[ "${config}" == "${clustercfgdefault}" ]; then
cp -nv "${lgsmdir}/default-configs/${clustercfgdefault}" "${clustercfgfullpath}"
else else
cp -v "${lgsmdir}/default-configs/${config}" "${servercfgdir}/${config}" fn_script_log_warn "Config file not found, cannot alter it."
fi echo "Config file not found, cannot alter it."
done
sleep 1 sleep 1
fi
} }
# Changes some variables within the default Don't Starve Together configs # Changes some variables within the default Don't Starve Together configs
@ -129,10 +132,10 @@ if [ "${gamename}" == "7 Days To Die" ]; then
fn_set_config_vars fn_set_config_vars
elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then
gamedirname="ARKSurvivalEvolved" gamedirname="ARKSurvivalEvolved"
fn_check_cfgdir
array_configs+=( GameUserSettings.ini ) array_configs+=( GameUserSettings.ini )
fn_fetch_default_config fn_fetch_default_config
fn_default_config_remote fn_default_config_remote
fn_set_config_vars
elif [ "${gamename}" == "ARMA 3" ]; then elif [ "${gamename}" == "ARMA 3" ]; then
gamedirname="Arma3" gamedirname="Arma3"
fn_check_cfgdir fn_check_cfgdir

Loading…
Cancel
Save