Skip to content

Commit d3d5740

Browse files
mtaserver.conf.template add header comment
1 parent 620e1d7 commit d3d5740

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

utils/buildactions/compose_files.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ local WINDOWS = os.host() == "windows"
1111
newaction {
1212
trigger = "compose_files",
1313
description = "Composes files that are required for building the installer",
14-
14+
1515
execute = function()
1616
os.mkdir(OUTPUT_DIR)
17-
17+
1818
-- Copy data files
1919
if WINDOWS then
2020
os.copydir(DATA_DIR.."/MTA", OUTPUT_DIR.."/MTA")
@@ -25,9 +25,9 @@ newaction {
2525

2626
-- Copy configs
2727
os.copydir("Server/mods/deathmatch", OUTPUT_DIR.."/server/mods/deathmatch", "*.conf")
28-
os.copyfile(OUTPUT_DIR.."/server/mods/deathmatch/mtaserver.conf", OUTPUT_DIR.."/server/mods/deathmatch/mtaserver.conf.template")
28+
os.makeconfigtemplate(OUTPUT_DIR.."/server/mods/deathmatch/mtaserver.conf", OUTPUT_DIR.."/server/mods/deathmatch/mtaserver.conf.template")
2929
os.copydir("Server/mods/deathmatch", OUTPUT_DIR.."/server/mods/deathmatch", "*.xml")
30-
30+
3131
-- Copy compiled binaries
3232
if WINDOWS then
3333
os.copydir(BIN_DIR, OUTPUT_DIR, "**.exe")

utils/buildactions/install_data.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ newaction {
4949
return
5050
end
5151

52-
if not os.copyfile(BIN_DIR.."/server/mods/deathmatch/mtaserver.conf", BIN_DIR.."/server/mods/deathmatch/mtaserver.conf.template") then
52+
if not os.makeconfigtemplate(BIN_DIR.."/server/mods/deathmatch/mtaserver.conf", BIN_DIR.."/server/mods/deathmatch/mtaserver.conf.template") then
5353
errormsg("ERROR: Could not copy mtaserver.conf to mtaserver.conf.template")
5454
os.exit(1)
5555
return
@@ -75,7 +75,7 @@ newaction {
7575
success = success and http.download_print_errors(NET_PATH_X64_WIN, BIN_DIR.."/server/x64/net.dll")
7676
success = success and http.download_print_errors(NET_PATH_ARM64_WIN, BIN_DIR.."/server/arm64/net.dll")
7777
success = success and http.download_print_errors(NETC_PATH_WIN, BIN_DIR.."/MTA/netc.dll")
78-
78+
7979
-- A download failed
8080
if not success then
8181
os.exit(1)

utils/buildactions/utils.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,25 @@ function errormsg(title, message)
153153
end
154154
term.popColor()
155155
end
156+
157+
-- Does a normal file copy and adds hardcoded text to the beginning of the resulting file
158+
-- Used in compose_files.lua and install_data.lua
159+
function os.makeconfigtemplate(file_path, result_path)
160+
if not os.copyfile(file_path, result_path) then
161+
return false
162+
end
163+
local result_file = io.open(result_path, "r")
164+
if not result_file then
165+
return false
166+
end
167+
local file_content = result_file:read("*all")
168+
result_file:close()
169+
result_file = io.open(result_path, "w")
170+
if not result_file then
171+
return false, "Failed to open result file for writing."
172+
end
173+
result_file:write("<!-- DELETING THIS FILE IS NOT RECOMMENDED ('mtaserver.conf.template')!\n It is automatically used by the server for inserting missing settings into 'mtaserver.conf' on startup.\n-->\n")
174+
result_file:write(file_content)
175+
result_file:close()
176+
return true
177+
end

0 commit comments

Comments
 (0)