Explorar o código

reword of dst config install

Removed install settings as it complicates setup. The admin  how has to manually setup a slave shard using configs. By default LinuxGSM will setup a Master shard. Docs will need to be updated.
Daniel Gibbs %!s(int64=2) %!d(string=hai) anos
pai
achega
50778477a3

+ 1 - 7
lgsm/config-default/config-lgsm/dstserver/_default.cfg

@@ -9,18 +9,12 @@
 #### Game Server Settings ####
 
 ## Predefined Parameters | https://docs.linuxgsm.com/configuration/start-parameters
-sharding="false"
-master="true"
-shard="Master"
 cluster="Cluster_1"
-cave="false"
-
-# Edit with care
 persistentstorageroot="${HOME}/.klei"
 confdir="DoNotStarveTogether"
 
 ## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
-startparameters="-persistent_storage_root ${persistentstorageroot} -conf_dir ${confdir} -cluster ${cluster} -shard ${shard}"
+startparameters="-persistent_storage_root ${persistentstorageroot} -conf_dir ${confdir} -cluster ${cluster}"
 
 #### LinuxGSM Settings ####
 

+ 35 - 68
lgsm/modules/install_config.sh

@@ -38,7 +38,7 @@ fn_default_config_remote() {
 	for config in "${array_configs[@]}"; do
 		fn_fetch_file "${githuburl}/${shortname}/${config}" "${remote_fileurl_backup}" "GitHub" "Bitbucket" "${lgsmdir}/config-default/config-game" "${config}" "nochmodx" "norun" "forcedl" "nohash"
 	done
-
+	fn_check_cfgdir
 	for config in "${array_configs[@]}"; do
 		# every config is copied
 		echo -en "copying config file [ ${italic}${config}${default} ]"
@@ -67,6 +67,7 @@ fn_default_config_remote() {
 
 # Copys local default config to server config location.
 fn_default_config_local() {
+	fn_check_cfgdir
 	echo -en "copying config file [ ${italic}${servercfgdefault}${default} ]"
 	cp -nv "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
 	if [ "${exitcode}" != 0 ]; then
@@ -83,13 +84,10 @@ fn_default_config_local() {
 # PASSWORD to random password
 fn_set_config_vars() {
 	if [ -f "${servercfgfullpath}" ]; then
-		random=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
 		servername="LinuxGSM"
-		rconpass="admin${random}"
-
 		echo -en "changing server name"
 		changes=""
-		# prevents var from being overwritten with the servername.
+		# prevents the variable SERVERNAME from being overwritten with the $servername.
 		if grep -q "SERVERNAME=SERVERNAME" "${lgsmdir}/config-default/config-game/${config}" 2> /dev/null; then
 			changes+=$(sed -i "s/SERVERNAME=SERVERNAME/SERVERNAME=${servername}/g w /dev/stdout" "${servercfgfullpath}")
 		elif grep -q "SERVERNAME=\"SERVERNAME\"" "${lgsmdir}/config-default/config-game/${config}" 2> /dev/null; then
@@ -100,7 +98,7 @@ fn_set_config_vars() {
 		if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
 			fn_print_fail_eol
 			fn_script_log_fatal "changing server name"
-		elif [ "$changes" != "" ]; then
+		elif [ "${changes}" != "" ]; then
 			fn_print_ok_eol_nl
 			fn_script_log_pass "changing server name"
 		else
@@ -108,7 +106,9 @@ fn_set_config_vars() {
 		fi
 		unset changes
 
-		echo -en "changing rcon/admin password"
+		randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
+		rconpass="admin${randomstring}"
+		echo -en "generating rcon/admin password"
 		changes=""
 		if [ "${shortname}" == "squad" ]; then
 			changes+=$(sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgdir}/Rcon.cfg")
@@ -117,10 +117,10 @@ fn_set_config_vars() {
 		fi
 		if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
 			fn_print_fail_eol
-			fn_script_log_fatal "changing rcon/admin password"
-		elif [ "$changes" != "" ]; then
+			fn_script_log_fatal "generating rcon/admin password"
+		elif [ "${changes}" != "" ]; then
 			fn_print_ok_eol_nl
-			fn_script_log_pass "changing rcon/admin password"
+			fn_script_log_pass "generating rcon/admin password"
 		else
 			fn_print_skip_eol_nl
 		fi
@@ -130,52 +130,35 @@ fn_set_config_vars() {
 
 # Changes some variables within the default Don't Starve Together configs.
 fn_set_dst_config_vars() {
-	## cluster.ini
-	if grep -Fq "SERVERNAME" "${clustercfgfullpath}"; then
-		echo -e "changing server name."
-		fn_script_log_info "changing server name."
-		sed -i "s/SERVERNAME/LinuxGSM/g" "${clustercfgfullpath}"
-		fn_sleep_time
-		echo -e "changing shard mode."
-		fn_script_log_info "changing shard mode."
-		sed -i "s/USESHARDING/${sharding}/g" "${clustercfgfullpath}"
-		fn_sleep_time
-		echo -e "randomizing cluster key."
-		fn_script_log_info "randomizing cluster key."
-		randomkey=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 8 | xargs)
-		sed -i "s/CLUSTERKEY/${randomkey}/g" "${clustercfgfullpath}"
-		fn_sleep_time
+	servername="LinuxGSM"
+	echo -en "changing cluster name"
+	changes=""
+	changes+=$(sed -i "s/SERVERNAME/${servername}/g" "${clustercfgfullpath}")
+	if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
+		fn_print_fail_eol
+		fn_script_log_fatal "changing cluster name"
+	elif [ "${changes}" != "" ]; then
+		fn_print_ok_eol_nl
+		fn_script_log_pass "changing cluster name"
 	else
-		echo -e "${clustercfg} is already configured."
-		fn_script_log_info "${clustercfg} is already configured."
-	fi
-
-	## server.ini
-	# removing unnecessary options (dependent on sharding & shard type).
-	if [ "${sharding}" == "false" ]; then
-		sed -i "s/ISMASTER//g" "${servercfgfullpath}"
-		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
-	elif [ "${master}" == "true" ]; then
-		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
+		fn_print_skip_eol_nl
 	fi
+	unset changes
 
-	echo -e "changing shard name."
-	fn_script_log_info "changing shard name."
-	sed -i "s/SHARDNAME/${shard}/g" "${servercfgfullpath}"
-	fn_sleep_time
-	echo -e "changing master setting."
-	fn_script_log_info "changing master setting."
-	sed -i "s/ISMASTER/${master}/g" "${servercfgfullpath}"
-	fn_sleep_time
-
-	## worldgenoverride.lua
-	if [ "${cave}" == "true" ]; then
-		echo -e "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
-		fn_script_log_info "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
-		echo 'return { override_enabled = true, preset = "DST_CAVE", }' > "${servercfgdir}/worldgenoverride.lua"
+	randomstring=$(tr -dc A-Za-z0-9 < /dev/urandom 2> /dev/null | head -c 16 | xargs)
+	echo -en "generating cluster key"
+	changes=""
+	changes+=$(sed -i "s/CLUSTERKEY/${randomstring}/g" "${clustercfgfullpath}")
+	if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
+		fn_print_fail_eol
+		fn_script_log_fatal "generating cluster key"
+	elif [ "${changes}" != "" ]; then
+		fn_print_ok_eol_nl
+		fn_script_log_pass "generating cluster key"
+	else
+		fn_print_skip_eol_nl
 	fi
-	fn_sleep_time
-	echo -e ""
+	unset changes
 }
 
 # Lists local config file locations
@@ -215,25 +198,21 @@ elif [ "${shortname}" == "ahl2" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "ark" ]; then
-	fn_check_cfgdir
 	array_configs+=(GameUserSettings.ini)
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "arma3" ]; then
-	fn_check_cfgdir
 	array_configs+=(server.cfg network.cfg)
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "armar" ]; then
-	fn_check_cfgdir
 	array_configs+=(server.json)
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "ats" ]; then
-	fn_check_cfgdir
 	array_configs+=(server_config.sii)
 	fn_default_config_remote
 	fn_set_config_vars
@@ -249,13 +228,11 @@ elif [ "${shortname}" == "bd" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "bt" ]; then
-	fn_check_cfgdir
 	array_configs+=(serversettings.xml)
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "btl" ]; then
-	fn_check_cfgdir
 	array_configs+=(DefaultGame.ini)
 	fn_default_config_remote
 	fn_set_config_vars
@@ -361,7 +338,6 @@ elif [ "${shortname}" == "ct" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "dayz" ]; then
-	fn_check_cfgdir
 	array_configs+=(server.cfg)
 	fn_default_config_remote
 	fn_set_config_vars
@@ -391,7 +367,6 @@ elif [ "${shortname}" == "dmc" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "dst" ]; then
-	fn_check_cfgdir
 	array_configs+=(cluster.ini server.ini)
 	fn_default_config_remote
 	fn_set_dst_config_vars
@@ -420,7 +395,6 @@ elif [ "${shortname}" == "etl" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "ets2" ]; then
-	fn_check_cfgdir
 	array_configs+=(server_config.sii)
 	fn_default_config_remote
 	fn_set_config_vars
@@ -516,7 +490,6 @@ elif [ "${shortname}" == "mohaa" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "mh" ]; then
-	fn_check_cfgdir
 	array_configs+=(Game.ini)
 	fn_default_config_remote
 	fn_set_config_vars
@@ -537,7 +510,6 @@ elif [ "${shortname}" == "nd" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "mta" ]; then
-	fn_check_cfgdir
 	array_configs+=(acl.xml mtaserver.conf vehiclecolors.conf)
 	fn_default_config_remote
 	fn_list_config_locations
@@ -547,7 +519,6 @@ elif [ "${shotname}" == "mom" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "pvr" ]; then
-	fn_check_cfgdir
 	array_configs+=(Game.ini)
 	fn_default_config_remote
 	fn_set_config_vars
@@ -557,13 +528,11 @@ elif [ "${shortname}" == "pvkii" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "pz" ]; then
-	fn_check_cfgdir
 	array_configs+=(server.ini)
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "nec" ]; then
-	fn_check_cfgdir
 	array_configs+=(server.cfg)
 	fn_default_config_remote
 	fn_set_config_vars
@@ -611,7 +580,6 @@ elif [ "${shortname}" == "rtcw" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "rust" ]; then
-	fn_check_cfgdir
 	array_configs+=(server.cfg)
 	fn_default_config_remote
 	fn_list_config_locations
@@ -695,7 +663,6 @@ elif [ "${shortname}" == "terraria" ]; then
 	fn_set_config_vars
 	fn_list_config_locations
 elif [ "${shortname}" == "tu" ]; then
-	fn_check_cfgdir
 	array_configs+=(TowerServer.ini)
 	fn_default_config_remote
 	fn_set_config_vars