luci-mod-admin-full: fstab: Add ability to redo the detection of block devices
authorDaniel Dickinson <openwrt@daniel.thecshore.com>
Wed, 2 Dec 2015 05:23:04 +0000 (00:23 -0500)
committerDaniel Dickinson <openwrt@daniel.thecshore.com>
Wed, 2 Dec 2015 07:17:20 +0000 (02:17 -0500)
Adds a button that does block detect and write the new configuration
to /etc/config/fstab.

modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/fstab.lua

index e6f207b2e8ffa12779f8394b35a30d65964eac7f..fd466d5c26563ab3a4c96877a9ec921ef0421a94 100644 (file)
@@ -33,12 +33,19 @@ until not ln
 
 block:close()
 
-
 m = Map("fstab", translate("Mount Points"))
 s = m:section(TypedSection, "global", translate("Global Settings"))
 s.addremove = false
 s.anonymous = true
 
+detect = s:option(Button, "block_detect", translate("Generate Config"), translate("Find all currently attached filesystems and swap and replace configuration with defaults based on what was detected"))
+detect.inputstyle = "reload"
+
+detect.write = function(self, section)
+       luci.sys.call("block detect >/etc/config/fstab")
+       luci.http.redirect(luci.dispatcher.build_url("admin/system", "fstab"))
+end
+
 o = s:option(Flag, "anon_swap", translate("Anonymous Swap"), translate("Mount swap not specifically configured"))
 o.default = o.disabled
 o.rmempty = false