[ UP ] update cgi. add display percentege bar icons.
[archserver.git] / cgi / raid / list_partitions.lua
blob10297509033a197b74d09119fc42e3bba1e56b20
1 #!/usr/bin/lua
3 dofile "libutil.lua"
5 t = myexec("sudo fdisk -l")
6 dt = {} -- device table
8 string.gsub(t, "\n(/.-)\n", function(l)
9 repeat
10 if (string.find(l, "Ext") or string.find(l, "extended")) then break end -- filter "extended" partition
11 string.gsub(l, "(.-)%s+%**%s+%d+%s+%d+%s+(%d+).-%x+%s+(.-)$", function(d, s, f)
12 dt[d] = {}
13 dt[d]["size"] = size2hum(s..'k')
14 dt[d]["fs"] = f
15 -- print("dev: "..d.."\tsize: "..size2hum(s.."K").."\tfilesystem: "..f)
16 end)
17 until true
18 end)
20 print([[
21 <form action = "volumes_create_raid.cgi" method = "post">
22 <table cellspacing="1" cellpadding="2" border="0" width="60%">
23 <tr align="left"><td bgcolor="#ebebeb"><strong>Partition</strong></td><td bgcolor="#ebebeb"><strong>Size</strong></td><td bgcolor="#ebebeb"><strong>Filesystem</strong></td></tr>
24 ]])
26 i = 0
27 for d in pairs(dt) do
28 v = one_two(v)
29 i = i + 1
30 _td1 = string.format([[<tr bgcolor=#c6d5a8 align="left"><td>
31 <input type="checkbox" name="devs_%d" value="%s">%s</td>]], v, i, d, d)
32 print(_td1)
33 print("<td>"..dt[d].size.."</td>")
34 print("<td>"..dt[d].fs.."</td></tr>")
35 end
37 print([[</table>
38 <input type="hidden" name=todo value="todo">
39 <input type="submit" value="创建阵列">
40 <input type="reset" value="清除">
41 </form>]])