applications/luci-initmgr: Changed header
[project/luci.git] / applications / luci-initmgr / luasrc / model / cbi / startup.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6 Copyright 2010 Manuel Munz <freifunk at somakoma dot de>
7
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
11
12         http://www.apache.org/licenses/LICENSE-2.0
13 ]]--
14
15 local fs = require "nixio.fs"
16 local rc = "/etc/rc.local" 
17
18 f = SimpleForm("rc", translate("Local Startup"), translate([[This is the content of /etc/rc.local. Insert your own commands here
19          (in front of 'exit 0') to execute them at the end of the boot process.]]))
20
21 t = f:field(TextValue, "rcs")
22 t.rmempty = true
23 t.rows = 20
24 function t.cfgvalue()
25         return fs.readfile(rc) or ""
26 end
27
28 function f.handle(self, state, data)
29         if state == FORM_VALID then
30                 if data.rcs then
31                         fs.writefile(rc, data.rcs:gsub("\r\n", "\n"))
32                 end
33         end
34         return true
35 end
36
37 return f