6 changed files with 258 additions and 199 deletions
@ -0,0 +1,144 @@ |
|||
#!/bin/bash |
|||
# LGSM game_settings.sh function |
|||
# Author: Jared Ballou |
|||
# Website: http://gameservermanagers.com |
|||
lgsm_version="180116" |
|||
|
|||
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" |
|||
local modulename="Settings" |
|||
|
|||
# Config files |
|||
cfg_file_default="${scriptcfgdir}/_default.cfg" |
|||
cfg_file_common="${scriptcfgdir}/_common.cfg" |
|||
cfg_file_instance="${scriptcfgdir}/${servicename}.cfg" |
|||
|
|||
# Config file headers |
|||
cfg_header_all="# Your settings for all servers go in _common.cfg\n# Server-specific settings go into \$SERVER.cfg" |
|||
cfg_header_default="# Default config - Changes will be overwritten by updates.\n${cfg_header_all}" |
|||
cfg_header_common="# Common config - Will not be overwritten by script.\n${cfg_header_all}" |
|||
cfg_header_instance="# Instance Config for ${servicename} - Will not be overwritten by script.\n${cfg_header_all}" |
|||
|
|||
|
|||
# If default config does not exist, create it. This should come from Git, and will be overwritten by updates. |
|||
# Rather than try to wget it from Github or other fancy ways to get it, the simplest way to ensure it works is to simply create it here. |
|||
fn_update_config() |
|||
{ |
|||
key=$1 |
|||
val=$2 |
|||
cfg_file=${3:-$cfg_file_default} |
|||
comment=${4:-""} |
|||
|
|||
# Get current key/value pair from file |
|||
exists=$(grep "^${key}=" $cfg_file 2>/dev/null) |
|||
exists_comment=$(echo $(echo $exists | cut -d'#' -f2-)) |
|||
case "${val}" in |
|||
""|"--UNSET--") |
|||
if [ "${exists}" != "" ]; then |
|||
echo "Removing ${key} from ${cfg_file}" |
|||
sed "/${key}=.*/d" -i $cfg_file |
|||
fi |
|||
return |
|||
;; |
|||
"--EMPTY--") |
|||
val="" |
|||
;; |
|||
esac |
|||
# Put " # " at beginning of comment if not empty |
|||
if [ "${comment}" != "" ] |
|||
then |
|||
comment=" # ${comment}" |
|||
else |
|||
if [ "${exists_comment}" != "" ]; then |
|||
comment=" # ${exists_comment}" |
|||
fi |
|||
fi |
|||
|
|||
# Line to be put in |
|||
data="${key}=\"${val}\"${comment}" |
|||
|
|||
# Check if key exists in config |
|||
if [ "${exists}" != "" ]; then |
|||
# If the line isn't the same as the parsed data line, replace it |
|||
if [ "${exists}" != "${data}" ]; then |
|||
#echo "Updating ${data} in ${cfg_file}" |
|||
sed -e "s/^${key}=.*\$/${data}/g" -i $cfg_file |
|||
#sed "/${key}=.*/${data}/" -i $cfg_file |
|||
fi |
|||
else |
|||
# If value does not exist, append to file |
|||
#echo "Adding ${data} to ${cfg_file}" |
|||
echo -ne "${data}\n" >> $cfg_file |
|||
fi |
|||
} |
|||
|
|||
fn_create_config(){ |
|||
cfg_type=${1:-default} |
|||
cfg_force=$2 |
|||
cfg_file="cfg_file_${cfg_type}" |
|||
cfg_header="cfg_header_${cfg_type}" |
|||
|
|||
cfg_dir=$(dirname ${!cfg_file}) |
|||
#If config directory does not exist, create it |
|||
if [ ! -e $cfg_dir ]; then mkdir -p $cfg_dir; fi |
|||
|
|||
# Create file header if needed |
|||
if [ ! -e ${!cfg_file} ] || [ "${cfg_force}" != "" ]; then |
|||
echo "Creating ${cfg_type} config at ${!cfg_file}" |
|||
echo -ne "${!cfg_header}\n\n" > ${!cfg_file} |
|||
# Dump in defaults for this game |
|||
if [ "${cfg_type}" == "default" ]; then |
|||
cat ${settingsdir}/settings >> ${!cfg_file} |
|||
fi |
|||
fi |
|||
} |
|||
|
|||
fn_flush_game_settings(){ |
|||
if [ -e $settingsdir ]; then |
|||
rm -rf $settingsdir > /dev/null |
|||
fi |
|||
mkdir -p $settingsdir |
|||
} |
|||
|
|||
fn_import_game_settings(){ |
|||
import="${gamesdir}/${1}" |
|||
if [ ! -e $import ]; then |
|||
fn_getgithubfile "games/${1}" |
|||
fi |
|||
source $import |
|||
} |
|||
|
|||
fn_set_game_params(){ |
|||
param_set=$1 |
|||
param_name=$2 |
|||
param_value=$3 |
|||
param_comment=$4 |
|||
fn_update_config "${param_name}" "${param_value}" "${settingsdir}/${param_set}" "${param_comment}" |
|||
} |
|||
|
|||
|
|||
fn_get_game_params(){ |
|||
param_set=$1 |
|||
param_name=$2 |
|||
param_default=$3 |
|||
} |
|||
|
|||
# Flush old setings buffer |
|||
fn_flush_game_settings |
|||
|
|||
# Import this game's settings |
|||
fn_import_game_settings $selfname |
|||
|
|||
# New method is to always run this function, it will overwrite defaults with whatever the new script values are |
|||
fn_create_config default |
|||
|
|||
# Load defaults |
|||
source $cfg_file_default |
|||
|
|||
# Load sitewide common settings (so that Git updates can safely overwrite default.cfg) |
|||
if [ ! -f $cfg_file_common ]; then fn_create_config common; else source $cfg_file_common; fi |
|||
|
|||
# Load instance specific settings |
|||
if [ ! -f $cfg_file_instance ]; then fn_create_config instance; else source $cfg_file_instance; fi |
|||
|
|||
|
|||
|
@ -0,0 +1,39 @@ |
|||
# Game Settings File |
|||
# csgoserver |
|||
# Counter-Strike: Global Offensive Dedicated Server |
|||
|
|||
# Import SRCDS |
|||
fn_import_game_settings _srcds |
|||
|
|||
# Add playlist parameter |
|||
fn_set_game_params parms_plus "+sv_playlist" "\${playlist}" |
|||
|
|||
# Override some server settings |
|||
fn_set_game_params settings "appid" "740" |
|||
fn_set_game_params settings "defaultmap" "de_dust2" |
|||
fn_set_game_params settings "game" "csgo" |
|||
fn_set_game_params settings "mapcyclefile" "--UNSET--" |
|||
fn_set_game_params settings "gamename" "Counter Strike: Global Offensive" |
|||
fn_set_game_params settings "mapgroup" "random_classic" "Map Group. See https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server" |
|||
fn_set_game_params settings "tickrate" "64" "Server Tick Rate" |
|||
fn_set_game_params settings "gametype" "0" "Game Type. Set to: Arms Race 1 Classic Casual 0 Classic Competitive 0 Demolition 1 Deathmatch 1" |
|||
fn_set_game_params settings "gamemode" "0" "Game Mode. Set to: Arms Race 0 Classic Casual 0 Classic Competitive 1 Demolition 1 Deathmatch 2" |
|||
fn_set_game_params settings "gslt" "--EMPTY--" "Required: Game Server Login Token. GSLT is required for running a public server. More info: http://gameservermanagers.com/gslt" |
|||
fn_set_game_params settings "authkey" "--EMPTY--" "Optional key for Workshop Content. See https://developer.valvesoftware.com/wiki/CSGO_Workshop_For_Server_Operators - To get an authkey visit - http://steamcommunity.com/dev/apikey" |
|||
fn_set_game_params settings "ws_collection_id" "--EMPTY--" "Workshop Collection ID" |
|||
fn_set_game_params settings "ws_start_map" "--EMPTY--" "Workshop Start Map" |
|||
|
|||
|
|||
# The parms that start with - go first |
|||
fn_set_game_params parms_minus "-usercon" "--EMPTY--" |
|||
fn_set_game_params parms_minus "-tickrate" "\${tickrate}" |
|||
fn_set_game_params parms_minus "-maxplayers_override" "\${maxplayers}" |
|||
fn_set_game_params parms_minus "-authkey" "\${authkey}" |
|||
|
|||
# Then the parms that start with + |
|||
fn_set_game_params parms_plus "+sv_setsteamaccount" "\${gslt}" |
|||
fn_set_game_params parms_plus "+mapgroup" "\${mapgroup}" |
|||
fn_set_game_params parms_plus "+game_mode" "\${gamemode}" |
|||
fn_set_game_params parms_plus "+game_type" "\${gametype}" |
|||
fn_set_game_params parms_plus "+host_workshop_collection" "\${ws_collection_id}" |
|||
fn_set_game_params parms_plus "+workshop_start_map" "\${ws_start_map}" |
@ -1,13 +1,17 @@ |
|||
# Game Settings File |
|||
# insurgency |
|||
# insserver |
|||
# Insurgency Dedicated Server |
|||
|
|||
fn_settings_import _srcds |
|||
# Import SRCDS |
|||
fn_import_game_settings _srcds |
|||
|
|||
fn_set_game_params params_plus "+sv_playlist" "\${playlist}" |
|||
# Add playlist parameter |
|||
fn_set_game_params parms_plus "+sv_playlist" "\${playlist}" |
|||
|
|||
# Override some server settings |
|||
fn_set_game_params settings "appid" "237410" |
|||
fn_set_game_params settings "defaultmap" "ministry checkpoint" |
|||
fn_set_game_params settings "game" "insurgency" |
|||
fn_set_game_params settings "mapcyclefile" "mapcycle.txt" |
|||
fn_set_game_params settings "playlist" "custom" "Server Playlist" |
|||
fn_set_game_params settings "gamename" "Insurgency" |
Loading…
Reference in new issue