[ UP ] update cgi, lvm and raid can work. add set time and shutdown function to syste...
[archserver.git] / cgi / system / shutdown.lua
blobba7625bcc195f81d1bf151550635311ad7152d63
1 #!/usr/bin/lua
3 dofile "libutil.lua"
5 function display()
6 print([[
7 <form action="system_shutdown.cgi" method="post">
8 <input type="hidden" name="todo" value="e">
9 <table cellpadding="8" cellspacing="2" border="0">
10 <tr>
11 <td class="color_table_heading" valign="top" align="left"><strong>希望计算机做什么</strong></td>
12 <td class="color_table_row1" valign="top" align="left"><input type="radio" name="todo" value="halt" checked="checked" />&nbsp;关闭服务器<br />
13 <input type="radio" name="todo" value="reboot" />&nbsp;重启服务器</td>
14 </tr>
15 <tr>
16 <td class="color_table_heading" valign="top" align="left"><strong>重启/关机前延迟时间</strong></td>
17 <td class="color_table_row2" valign="top" align="left"><input type="text" name="delay" size="3" value="0" />&nbsp;&nbsp;分钟</td>
18 </tr>
19 <tr>
20 <td colspan="2" align="center"><input type="submit" value="重启/关机" /></td>
21 </tr>
22 </table>
23 </form>
24 ]])
25 end
26 local qp = ui_getqp()
27 print("<h3> 重启/关闭 服务器</h3>")
28 if not qp.todo then
29 display()
30 else
31 local cmd = ""
32 local err, ret
33 if qp.todo == "halt" then
34 cmd = "sudo shutdown -h"
35 else
36 cmd = "sudo shutdown -r"
37 end
38 cmd = cmd.." +"..qp.delay.." &"
40 err, ret = myexec(cmd)
41 if ret ~= 0 then ui_message_err(err) end
42 end