Skip to content

Commit

Permalink
updates the downloaded list of files
Browse files Browse the repository at this point in the history
adds a destination to share fw files
changes firmware repo
fixes get_repo_base_url()
  • Loading branch information
javierajorge committed Dec 1, 2023
1 parent c58fdad commit e04af02
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ local mesh_upgrade = {

-- Get the base url for the firmware repository in this node
function mesh_upgrade.get_repo_base_url()
ipv4, ipv6 = network.primary_address()
return "http://" .. ipv4 .. mesh_upgrade.FIRMWARE_REPO_PATH
local ipv4, ipv6 = network.primary_address()
return "http://" .. ipv4:host():string() .. mesh_upgrade.FIRMWARE_REPO_PATH
end

-- Create a work directory if nor exist
Expand All @@ -60,7 +60,7 @@ function mesh_upgrade.set_workdir(workdir)
mesh_upgrade.WORKDIR = workdir
mesh_upgrade.LATEST_JSON_FILE_NAME = "firmware_latest_mesh_wide.json" -- latest json with local lan url file name
mesh_upgrade.LATEST_JSON_PATH = mesh_upgrade.WORKDIR .. "/" .. mesh_upgrade.LATEST_JSON_FILE_NAME -- latest json full path
mesh_upgrade.FIRMWARE_REPO_PATH = 'lros' -- path url for firmwares
mesh_upgrade.FIRMWARE_REPO_PATH = '/lros/' -- path url for firmwares
mesh_upgrade.FIRMWARE_SHARED_FOLDER = '/www/' .. mesh_upgrade.FIRMWARE_REPO_PATH
end
mesh_upgrade.set_workdir("/tmp/mesh_upgrade")
Expand Down Expand Up @@ -90,6 +90,9 @@ function mesh_upgrade.create_local_latest_json(latest_data)
end

function mesh_upgrade.share_firmware_packages(dest)
if dest == nil then
dest = "/www" .. mesh_upgrade.FIRMWARE_REPO_PATH
end
local images_folder = eupgrade.WORKDIR
mesh_upgrade._configure_workdir(dest)
os.execute("ln -s " .. images_folder .. "/* " .. dest )
Expand Down Expand Up @@ -136,6 +139,8 @@ function mesh_upgrade.become_master_node()
if not utils.file_exists(mesh_upgrade.FIRMWARE_SHARED_FOLDER) then
return { code = "NO_SHARED_FOLDER", error = "Shared folder not found"}
end
--reshare downloaded files
mesh_upgrade.share_firmware_packages()
-- If we get here is supposed that everything is ready to be a master node
mesh_upgrade.inform_download_location(latest['version'])
return { code = "SUCCESS"}
Expand Down

0 comments on commit e04af02

Please sign in to comment.