2008-06-08 08:14:31 +00:00
--[[
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth < steven @ midlink.org >
2010-11-08 18:27:34 +00:00
Copyright 2010 Jo - Philipp Wich < xm @ subsignal.org >
2008-06-08 08:14:31 +00:00
Licensed under the Apache License , Version 2.0 ( the " License " ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : // www.apache . org / licenses / LICENSE - 2.0
$ Id $
] ] --
2010-11-08 18:27:34 +00:00
2008-05-25 17:00:30 +00:00
require ( " luci.config " )
2009-10-31 15:54:11 +00:00
m = Map ( " luci " , translate ( " Web <abbr title= \" User Interface \" >UI</abbr> " ) , translate ( " Here you can customize the settings and the functionality of <abbr title= \" Lua Configuration Interface \" >LuCI</abbr>. " ) )
2008-04-11 19:03:30 +00:00
2009-07-19 00:24:58 +00:00
local fs = require " nixio.fs "
2008-09-20 22:11:41 +00:00
-- force reload of global luci config namespace to reflect the changes
function m . commit_handler ( self )
package.loaded [ " luci.config " ] = nil
require ( " luci.config " )
end
2009-10-31 15:54:11 +00:00
c = m : section ( NamedSection , " main " , " core " , translate ( " General " ) )
2008-04-11 19:03:30 +00:00
2009-10-31 15:54:11 +00:00
l = c : option ( ListValue , " lang " , translate ( " Language " ) )
2009-01-14 23:47:56 +00:00
l : value ( " auto " )
2008-07-06 15:19:26 +00:00
2010-03-13 20:13:41 +00:00
local i18ndir = luci.i18n . i18ndir .. " base. "
2009-05-27 08:59:02 +00:00
for k , v in luci.util . kspairs ( luci.config . languages ) do
2009-04-04 22:54:16 +00:00
local file = i18ndir .. k : gsub ( " _ " , " - " )
2009-08-16 04:51:28 +00:00
if k : sub ( 1 , 1 ) ~= " . " and fs.access ( file .. " .lmo " ) then
2008-04-12 19:24:08 +00:00
l : value ( k , v )
end
end
2009-10-31 15:54:11 +00:00
t = c : option ( ListValue , " mediaurlbase " , translate ( " Design " ) )
2008-05-25 17:00:30 +00:00
for k , v in pairs ( luci.config . themes ) do
2008-04-12 19:24:08 +00:00
if k : sub ( 1 , 1 ) ~= " . " then
t : value ( v , k )
end
end
2008-04-11 19:03:30 +00:00
2009-10-31 15:54:11 +00:00
u = m : section ( NamedSection , " uci_oncommit " , " event " , translate ( " Post-commit actions " ) ,
translate ( " These commands will be executed automatically when a given <abbr title= \" Unified Configuration Interface \" >UCI</abbr> configuration is committed allowing changes to be applied instantly. " ) )
2008-04-11 19:03:30 +00:00
u.dynamic = true
2010-11-08 18:27:34 +00:00
f = m : section ( NamedSection , " main " , " core " , translate ( " Files to be kept when flashing a new firmware " ) )
f : tab ( " detected " , translate ( " Detected Files " ) ,
translate ( " The following files are detected by the system and will be kept automatically during sysupgrade " ) )
f : tab ( " custom " , translate ( " Custom Files " ) ,
translate ( " This is a list of shell glob patterns for matching files and directories to include during sysupgrade " ) )
d = f : taboption ( " detected " , DummyValue , " _detected " , translate ( " Detected files " ) )
d.rawhtml = true
d.cfgvalue = function ( s )
local list = io.popen (
" ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
" /lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
" opkg list-changed-conffiles ) | sort -u "
)
if list then
local files = { " <ul> " }
while true do
local ln = list : read ( " *l " )
if not ln then
break
else
files [ # files + 1 ] = " <li> "
files [ # files + 1 ] = luci.util . pcdata ( ln )
files [ # files + 1 ] = " </li> "
end
end
list : close ( )
files [ # files + 1 ] = " </ul> "
return table.concat ( files , " " )
end
2010-11-08 18:29:30 +00:00
return " <em> " .. translate ( " No files found " ) .. " </em> "
2010-11-08 18:27:34 +00:00
end
c = f : taboption ( " custom " , TextValue , " _custom " , translate ( " Custom files " ) )
c.rmempty = false
c.cols = 70
c.rows = 30
c.cfgvalue = function ( self , section )
return nixio.fs . readfile ( " /etc/sysupgrade.conf " )
end
c.write = function ( self , section , value )
return nixio.fs . writefile ( " /etc/sysupgrade.conf " , value )
end
2008-04-12 19:24:08 +00:00
2008-09-20 22:11:41 +00:00
return m