mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
9116317834
* greatly simplify docker * back to gcc since I can't the libs to load properly * fix typo add set -e to entrypoint better copy of entrypoint.sh and use proper entrypoint * use debian instead of gcc for runtime comment and organize it a bit drop gcc to 12 since we are using debian 12 as well * explicitly include mariadb libs * Make the server not crash in the case we are using only env-vars make the dockerfile have configs in the expected location incase of bypassing entrypoint.sh * remove unneede var from example, since it's in the container now * coments to dockerfile * Revert master server changes * Resolve conflicting port options between chat, master, and world move chat_server_port to shared since it's used by world and chat * Don't error if file does not exists when updating a config option move update before and use bin dir var
52 lines
1.8 KiB
CMake
52 lines
1.8 KiB
CMake
# Parses a config file for a specific option and appends the new option if it does not exist
|
|
# If the new option does exist, this function will do nothing.
|
|
# file_name: The name of the file to parse
|
|
# old_option_name: The name of the option to find
|
|
# new_option_name: The name of the option to add
|
|
function(UpdateConfigOption file_name old_option_name new_option_name)
|
|
string(APPEND old_option_name "=")
|
|
string(APPEND new_option_name "=")
|
|
message(STATUS "Checking " ${file_name} " for " ${old_option_name} " and adding " ${new_option_name} " if it does not exist")
|
|
if(NOT EXISTS ${file_name})
|
|
message(STATUS ${file_name} " does not exist. Doing nothing")
|
|
return()
|
|
endif()
|
|
file(READ ${file_name} current_file_contents)
|
|
string(REPLACE "\\\n" "" current_file_contents ${current_file_contents})
|
|
string(REPLACE "\n" ";" current_file_contents ${current_file_contents})
|
|
set(parsed_current_file_contents "")
|
|
|
|
# Remove comment lines so they do not interfere with the variable parsing
|
|
foreach(line ${current_file_contents})
|
|
string(FIND ${line} "#" is_comment)
|
|
|
|
if(NOT ${is_comment} EQUAL 0)
|
|
string(APPEND parsed_current_file_contents ${line})
|
|
endif()
|
|
endforeach()
|
|
|
|
set(found_new_option -1)
|
|
set(found_old_option -1)
|
|
set(current_value -1)
|
|
|
|
foreach(line ${current_file_contents})
|
|
string(FIND ${line} ${old_option_name} old_option_in_file)
|
|
|
|
if(${old_option_in_file} EQUAL 0)
|
|
set(found_old_option 1)
|
|
set(current_value ${line})
|
|
endif()
|
|
|
|
string(FIND ${line} ${new_option_name} found_new_option_in_file)
|
|
|
|
if(${found_new_option_in_file} EQUAL 0)
|
|
set(found_new_option 1)
|
|
endif()
|
|
endforeach(line ${current_file_contents})
|
|
|
|
if(${found_old_option} EQUAL 1 AND NOT ${found_new_option} EQUAL 1)
|
|
string(REPLACE ${old_option_name} ${new_option_name} current_value ${current_value})
|
|
file(APPEND ${file_name} "\n" ${current_value})
|
|
endif()
|
|
endfunction()
|