Skip to content

Commit

Permalink
do not overwrite services from template if service configuration alre…
Browse files Browse the repository at this point in the history
…ady exists
  • Loading branch information
cryi committed Oct 9, 2024
1 parent 68e41ae commit 38eaf02
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 68 deletions.
44 changes: 0 additions & 44 deletions containers/alpine/Containerfile

This file was deleted.

18 changes: 0 additions & 18 deletions containers/minimal/Containerfile

This file was deleted.

4 changes: 0 additions & 4 deletions containers/tezos/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ fi\n' > /usr/local/bin/auth_wget && chmod +x /usr/local/bin/auth_wget
# Use auth_wget for downloading files with optional authentication
RUN auth_wget https://raw.githubusercontent.com/alis-is/ascend/main/tools/setup/standalone-linux.sh -O /tmp/setup-ascend.sh && sh /tmp/setup-ascend.sh --prerelease

# RUN mkdir -p ${ASCEND_HEALTHCHECKS}
# COPY tools/healthchecks/baker ${ASCEND_HEALTHCHECKS}/baker
# RUN chmod +x ${ASCEND_HEALTHCHECKS}/baker

RUN mkdir -p /tezbox /tezbox/configuration /tezbox/overrides /tezbox/overrides/context
COPY configuration /tezbox/configuration
RUN chown -R tezos:tezos /tezbox
Expand Down
14 changes: 13 additions & 1 deletion src/box/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ local function inject_ascend_services(protocol, bakers, options)
local service_templates_directory = path.combine(serviceDirectory, "template")
local baker_service_template = fs.read_file(path.combine(service_templates_directory, "baker.json"))
for bakerId, bakerOptions in pairs(bakers) do
local serviceFilePath = path.combine(servicesDirectory, bakerId .. ".hjson")
if fs.exists(serviceFilePath) then
log_debug("service file " .. serviceFilePath .. " already exists, skipping")
goto continue
end

local args = { "run", "with", "local", "node", "${HOME}/.tezos-node", bakerId, "--votefile", "${VOTE_FILE}" }
if table.is_array(bakerOptions.args) then
for _, arg in ipairs(bakerOptions.args) do
Expand All @@ -120,18 +126,23 @@ local function inject_ascend_services(protocol, bakers, options)
}, { overwrite = true })
baker_service_template = baker_service_template:gsub("\"${BAKER_ARGS}\"", "${BAKER_ARGS}")
local service = string.interpolate(baker_service_template, vars)
local serviceFilePath = path.combine(servicesDirectory, bakerId .. ".hjson")

local ok = fs.safe_write_file(serviceFilePath, service)
if not ok then
log_error("failed to write service file " .. serviceFilePath)
os.exit(1)
end
::continue::
end

local serviceExtraTemplatesDirectory = path.combine(serviceDirectory, "extra")
for _, extraServiceFileName in ipairs(extraServices) do
local serviceTemplatePath = path.combine(serviceExtraTemplatesDirectory, extraServiceFileName .. ".json")
local serviceFilePath = path.combine(servicesDirectory, extraServiceFileName .. ".hjson")
if fs.exists(serviceFilePath) then
log_debug("service file " .. serviceFilePath .. " already exists, skipping")
goto continue
end

local serviceTemplate = fs.read_file(serviceTemplatePath)
local service = string.interpolate(serviceTemplate, vars)
Expand All @@ -140,6 +151,7 @@ local function inject_ascend_services(protocol, bakers, options)
log_error("failed to copy extra service file " .. serviceTemplatePath .. " to " .. serviceFilePath)
os.exit(1)
end
::continue::
end

-- healthchecks
Expand Down
2 changes: 1 addition & 1 deletion src/version-info.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local TEZBOX_VERSIOn = "0.3.0"
local TEZBOX_VERSIOn = "0.3.1"

return {
VERSION = TEZBOX_VERSIOn,
Expand Down

0 comments on commit 38eaf02

Please sign in to comment.