From 71f350a38aea67981289f1c1945653e7d09f33ea Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 17 Sep 2009 16:12:13 +0000 Subject: Added get_interfaces function to model, bumped to 0.5.7 New function used by new acf-iproute2-qos package --- Makefile | 2 +- interfaces-model.lua | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0f7e388..70a67a4 100644 --- a/Makefile +++ b/Makefile @@ -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)) -- cgit v1.2.3