Changeset 6744

Show
Ignore:
Timestamp:
01/15/11 20:13:19 (2 years ago)
Author:
soma
Message:

modules/freifunk: When olsrd was loaded but there were no neighbors then the page for services was showing an error.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/modules/freifunk/luasrc/view/freifunk-services/services.htm

    r6626 r6744  
    22 
    33<% 
    4 require("luci.fs") 
    5 require("luci.util") 
     4local fs  = require "luci.fs" 
     5local utl = require "luci.util" 
    66 
    77-- check if nameservice plugin is enabled and where to find the services file 
    88local has_services = false 
     9 
    910local uci = require "luci.model.uci".cursor() 
    1011uci:foreach("olsrd", "LoadPlugin", function(s) 
    1112    if s.library == "olsrd_nameservice.so.0.3" then 
    12         if s.services_file then 
     13        if s.services_file and fs.access(s.services_file) then 
    1314            has_services = true 
    1415            services_file = s.services_file 
    1516        else 
    16             has_services = true 
    17             services_file = "/var/run/services_olsr" 
     17            if fs.access("/var/run/services_olsr") then 
     18                has_services = true 
     19                services_file = "/var/run/services_olsr" 
     20            end 
    1821        end 
    1922    end 
     
    2225 
    2326function fetch_services() 
    24     local rawdata = luci.fs.readfile(services_file) 
     27    local rawdata = fs.readfile(services_file) 
    2528 
    2629    if #rawdata == 0 then 
     
    3033    local data = {} 
    3134 
    32     local tables = luci.util.split(luci.util.trim(rawdata), "\n", nil, true) 
     35    local tables = utl.split(utl.trim(rawdata), "\n", nil, true) 
    3336    -- remove the first 3 lines 
    3437    table.remove(tables,1) 
     
    4144 
    4245    for i, tbl in ipairs(tables) do 
    43         local lines = luci.util.split(tbl, "\n", nil, true) 
     46        local lines = utl.split(tbl, "\n", nil, true) 
    4447    end 
    4548     
     
    6568        local field = {} 
    6669        -- split line at # and |, 1=url, 2=proto, 3=description, 4=source 
    67         local field = luci.util.split(line, "[#|]", split, true) 
     70        local field = utl.split(line, "[#|]", split, true) 
    6871        local url,descr,origin = pcdata(field[1]),pcdata(field[3]),pcdata(field[4]) 
    6972        %>