diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-09-17 16:12:13 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-09-17 16:12:13 +0000 |
commit | 71f350a38aea67981289f1c1945653e7d09f33ea (patch) | |
tree | 826ce1e8e09ea72ee7d00b9ec8e2a414757acbe4 | |
parent | 220faadc8e96066de54c4a879bcf93dc9a4e7eae (diff) | |
download | acf-alpine-baselayout-71f350a38aea67981289f1c1945653e7d09f33ea.tar.bz2 acf-alpine-baselayout-71f350a38aea67981289f1c1945653e7d09f33ea.tar.xz |
Added get_interfaces function to model, bumped to 0.5.7v0.5.7
New function used by new acf-iproute2-qos package
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | interfaces-model.lua | 16 |
2 files changed, 17 insertions, 1 deletions
@@ -1,6 +1,6 @@ APP_NAME=alpine-baselayout PACKAGE=acf-$(APP_NAME) -VERSION=0.5.6 +VERSION=0.5.7 APP_DIST=\ alpine-baselayout.roles \ diff --git a/interfaces-model.lua b/interfaces-model.lua index ea18e56..66132b3 100644 --- a/interfaces-model.lua +++ b/interfaces-model.lua @@ -407,6 +407,22 @@ write_file = function (newfile) return modelfunctions.setfiledetails(newfile, {filename}) end +get_interfaces = function() + local cmd = path.."ip addr" + local f = io.popen(format.escapespecialcharacters(cmd)) + local ipaddr = f:read("*a") + f:close() + -- now parse the result to find the interfaces + local retval = {} + for line in string.gmatch(ipaddr, "[^\n]*\n?") do + if string.find(line, "^%d+:%s+") then + local interface=string.match(line, "^%d+:%s+([^:@]+)") + retval[#retval+1] = interface + end + end + return cfe({ type="list", value=retval, label="IP Interfaces" }) +end + get_addresses = function() local cmd = path.."ip addr" local f = io.popen(format.escapespecialcharacters(cmd)) |