summaryrefslogtreecommitdiff
path: root/updater-ng/files/turris.lua
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2018-10-15 14:49:25 +0200
committerKarel Kočí <karel.koci@nic.cz>2018-10-15 14:49:25 +0200
commitd093b44a67e7359de34a936454e977fa190bfb82 (patch)
tree315569314471984b648810d0f395fb582bef96fc /updater-ng/files/turris.lua
parent37f4c17c9b04538f2729003d9e28d3a8b8c53181 (diff)
downloadopenwrt-personal-pkgs-d093b44a67e7359de34a936454e977fa190bfb82.tar.gz
openwrt-personal-pkgs-d093b44a67e7359de34a936454e977fa190bfb82.tar.bz2
openwrt-personal-pkgs-d093b44a67e7359de34a936454e977fa190bfb82.zip
updater-ng: add missing file
Diffstat (limited to 'updater-ng/files/turris.lua')
-rw-r--r--updater-ng/files/turris.lua76
1 files changed, 76 insertions, 0 deletions
diff --git a/updater-ng/files/turris.lua b/updater-ng/files/turris.lua
new file mode 100644
index 0000000..5559507
--- /dev/null
+++ b/updater-ng/files/turris.lua
@@ -0,0 +1,76 @@
+--[[
+This file is part of updater-ng. Don't edit it.
+]]
+
+local branch = "hbs"
+local lists
+local datacollection_enabled = false
+if uci then
+ local cursor = uci.cursor()
+ uci_branch = cursor:get("updater", "override", "branch")
+ if uci_branch then
+ WARN("Branch overriden to " .. uci_branch)
+ branch = uci_branch
+ end
+ lists = cursor:get("updater", "pkglists", "lists")
+ -- TODO this can also be for example yes but this should work in default
+ datacollection_enabled = cursor:get("foris", "eula", "agreed_collect") == '1'
+else
+ ERROR("UCI library is not available. Configuration not used.")
+end
+
+-- TODO Turris 1.x contract? Or should we drop it.
+
+-- Guess what board this is.
+local base_model = ""
+if model then
+ if model:match("Turris Mox") then
+ base_model = "mox"
+ elseif model:match("[Oo]mnia") then
+ base_model = "omnia"
+ elseif model:match("[Tt]urris") then
+ base_model = "turris"
+ end
+end
+
+-- Definitions common url base
+local base_url = "https://repo.turris.cz/" .. base_model .. '-' .. branch .. "/lists/"
+-- Reused options for remotely fetched scripts
+local script_options = {
+ security = "Remote",
+ ca = system_cas,
+ crl = no_crl,
+ pubkey = {
+ "file:///etc/updater/keys/release.pub",
+ "file:///etc/updater/keys/standby.pub",
+ "file:///etc/updater/keys/test.pub" -- It is normal for this one to not be present in production systems
+ }
+}
+
+-- The distribution base script. It contains the repository and bunch of basic packages
+Script("base", base_url .. "base.lua", script_options)
+
+-- Data collection list
+if datacollection_enabled then
+ Script("base", base_url .. "i_agree_datacollect.lua", script_options)
+end
+
+-- Additional enabled distribution lists
+if lists then
+ if type(lists) == "string" then -- if there is single list then uci returns just a string
+ lists = {lists}
+ end
+ -- Go through user lists and pull them in.
+ local exec_list = {} -- We want to run userlist only once even if it's defined multiple times
+ if type(lists) == "table" then
+ for _, l in ipairs(lists) do
+ if exec_list[l] then
+ WARN("User list " .. l .. " specified multiple times")
+ else
+ Script("userlist-" .. l, base_url .. l .. ".lua", script_options)
+ exec_list[l] = true
+ end
+ end
+ end
+end
+