|
|
@ -28,10 +28,7 @@ fn_info_game_ini() { |
|
|
|
# q at the end of the s command tells sed to quit after the first match. |
|
|
|
# tr -d '\r' removes CRLF carriage returns from the end of the line. |
|
|
|
|
|
|
|
if [ -n "${3}" ]; then |
|
|
|
servercfgfullpath="${3}" |
|
|
|
fi |
|
|
|
eval "${1}=\"$(sed -n '/^[[:space:]]*\<'"${2}"'\>/ { s/.*= *"\?\([^"]*\)"\?/\1/p;q }' "${servercfgfullpath}" | tr -d '\r')\"" |
|
|
|
eval "${1}=\"$(sed -n '/^[[:space:]]*\<'"${2}"'\>/ { s/.*= *"\?\([^"]*\)"\?/\1/p;q }' "${3}" | tr -d '\r')\"" |
|
|
|
configtype="ini" |
|
|
|
} |
|
|
|
|
|
|
@ -50,38 +47,25 @@ fn_info_game_quakec() { |
|
|
|
# p at the end of the s command tells sed to print the resulting line if there was a match. |
|
|
|
# q at the end of the s command tells sed to quit after the first match. |
|
|
|
|
|
|
|
if [ -n "${3}" ]; then |
|
|
|
servercfgfullpath="${3}" |
|
|
|
fi |
|
|
|
eval "${1}"="$(sed -n "s/^.*${2}\s\+\"\(.*\)\"/\1/p;q" "${servercfgfullpath}")" |
|
|
|
|
|
|
|
eval "${1}"="$(sed -n "s/^.*${2}\s\+\"\(.*\)\"/\1/p;q" "${3}")" |
|
|
|
} |
|
|
|
|
|
|
|
# Config Type: json |
|
|
|
# Comment: // or /* */ |
|
|
|
fn_info_game_json() { |
|
|
|
if [ -n "${3}" ]; then |
|
|
|
servercfgfullpath="${3}" |
|
|
|
fi |
|
|
|
eval "${1}"="$(jq -r '${2}' "${servercfgfullpath}")" |
|
|
|
eval "${1}"="$(jq -r '${2}' "${3}")" |
|
|
|
} |
|
|
|
|
|
|
|
# Config Type: SQF |
|
|
|
# Comment: // or /* */ |
|
|
|
fn_info_game_sqf() { |
|
|
|
if [ -n "${3}" ]; then |
|
|
|
servercfgfullpath="${3}" |
|
|
|
fi |
|
|
|
eval "${1}"="$(sed -n "/^[^/]*${2} = \"\(.*\)\";/{s//\1/;p;q;}" "${servercfgfullpath}")" |
|
|
|
eval "${1}"="$(sed -n "/^[^/]*${2} = \"\(.*\)\";/{s//\1/;p;q;}" "${3}")" |
|
|
|
} |
|
|
|
|
|
|
|
# Config Type: XML |
|
|
|
# Comment: <!-- --> |
|
|
|
fn_info_game_xml() { |
|
|
|
if [ -n "${3}" ]; then |
|
|
|
servercfgfullpath="${3}" |
|
|
|
fi |
|
|
|
eval "${1}"="$(xmllint --xpath "string(${2})" "${servercfgfullpath}")" |
|
|
|
eval "${1}"="$(xmllint --xpath "string(${2})" "${3}")" |
|
|
|
} |
|
|
|
|
|
|
|
# Config Type: ini |
|
|
@ -216,6 +200,11 @@ fn_info_game_dodr() { |
|
|
|
# Example: cluster_name = SERVERNAME |
|
|
|
# Filetype: ini |
|
|
|
fn_info_game_dst() { |
|
|
|
if [ -f "${servercfgfullpath}" ]; then |
|
|
|
fn_info_game_ini "port" "server_port" "${servercfgfullpath}" |
|
|
|
fn_info_game_ini "steamauthport" "authentication_port" "${servercfgfullpath}" |
|
|
|
fn_info_game_ini "steammasterport" "master_server_port" "${servercfgfullpath}" |
|
|
|
fi |
|
|
|
if [ -f "${clustercfgfullpath}" ]; then |
|
|
|
fn_info_game_ini "maxplayers" "max_players" "${clustercfgfullpath}" |
|
|
|
fn_info_game_ini "servername" "cluster_name" "${clustercfgfullpath}" |
|
|
@ -225,11 +214,6 @@ fn_info_game_dst() { |
|
|
|
fn_info_game_ini "gamemode" "game_mode" "${clustercfgfullpath}" |
|
|
|
fn_info_game_ini "configip" "bind_ip" "${clustercfgfullpath}" |
|
|
|
fi |
|
|
|
if [ -f "${servercfgfullpath}" ]; then |
|
|
|
fn_info_game_ini "port" "server_port" "${servercfgfullpath}" |
|
|
|
fn_info_game_ini "steamauthport" "authentication_port" "${servercfgfullpath}" |
|
|
|
fn_info_game_ini "steammasterport" "master_server_port" "${servercfgfullpath}" |
|
|
|
fi |
|
|
|
cave="${cave:-"NOT SET"}" |
|
|
|
cluster="${cluster:-"NOT SET"}" |
|
|
|
configip="${configip:-"0.0.0.0"}" |
|
|
|