#!/usr/bin/luaweb
json = require("json")
omg = require("omg")

function readAll(f)
   local f = io.open(file, "rb")
   local content = f:read("*all")
   f:close()
   return content
end

local f
f = io.open("/data/ipconfig.json","r")
if f ~= nil then
    local content = f:read("*all")
    if content ~= nil and string.len(content) > 0 then
        ip_address_table = json.decode(content)
    end
elseif f==nil then
    f = io.open("/data/ipconfig.lua","r")
    if f ~= nil then
        dofile("/data/ipconfig.lua")
    end
end

if f then
    io.close(f)
    if my_ip_address_table ~= nil then
       ip_address_table={}
       ip_address_table["V4"] = my_ip_address_table
       ip_address_table["V6"] = my_ip_address6_table 
    end
    if ip_address_table ~= nil then
        omg.runScript(ip_address_table,arg,"show iptables and routing settings\n")
    end
end




