diff options
Diffstat (limited to 'interfaces-model.lua')
-rw-r--r-- | interfaces-model.lua | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/interfaces-model.lua b/interfaces-model.lua index b0d3b05..efc5ed9 100644 --- a/interfaces-model.lua +++ b/interfaces-model.lua @@ -15,13 +15,26 @@ local iface = { tags = { "name", "comment", "method", "address", "netmask", "gateway", "hostname", "provider", "pre-up", "up", "down", "post-down" }, methods = { "dhcp", "static", "ppp", "loopback", "manual" }, + label = { ['name']="Interface names" , + ['comment']="Comments", + ['method']="Method", + ['address']="Address", + ['netmask']="Netmask", + ['gateway']="Gateway", + ['hostname']="Hostname", + ['provider']="Provider", + ['pre-up']="'pre-up' actions", + ['up']="'up' actions", + ['down']="'down' actions", + ['post-down']="'post-down' actions", + }, -- lowlevel functions will insert file and array here } -- Lowlevel functions - they do things directly to iface. +local filename = "/etc/network/interfaces" iface.read_file = function () - local filename = "/etc/network/interfaces" iface.file = cfe { name=filename, filename=filename } local file = io.open(filename) local rc = false @@ -49,14 +62,14 @@ iface.write_file = function () function iface.iface_type ( ) local f = {} for k,v in pairs(iface.tags) do - f[v] = cfe { name = v } + f[v] = cfe { name = v, label = (iface.label[v] or "") } end for k,v in pairs ({"comment", "pre-up", "up", "down", "post-down"}) do f[v].type ="longtext" end - + f.method.type = "select" f.method.option = iface.methods return (f) @@ -141,6 +154,7 @@ function iface.unpack_interfaces () local param, val = string.match(line, "(%S+)%s*(.*)$") if (param) then + if not (array[count][param]) then array[count][param] = {} end array[count][param].value = iface.append (array[count][param].value, val) end @@ -281,4 +295,12 @@ end delete_iface_by_name = iface.delete - +get_status = function () + local status = {} + status.interfacesfile = cfe({ + name="interfacesfile", + label="Interfaces file", + value=filename, + }) + return status +end |