diff options
author | Ted Trask <ttrask01@yahoo.com> | 2012-12-26 21:31:05 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2012-12-26 21:31:05 +0000 |
commit | 8f8b9ceb346b8d102c02ce37700c10ae313fcd1e (patch) | |
tree | d25d69757dadef6517918e06969bf03f48b2d562 /hostname-model.lua | |
parent | a3d85f4a1a4c7a5856a4c6ddec2db9115a54ab89 (diff) | |
download | acf-alpine-baselayout-8f8b9ceb346b8d102c02ce37700c10ae313fcd1e.tar.bz2 acf-alpine-baselayout-8f8b9ceb346b8d102c02ce37700c10ae313fcd1e.tar.xz |
Replace io.popen with modelfunction.run_executable
Diffstat (limited to 'hostname-model.lua')
-rw-r--r-- | hostname-model.lua | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/hostname-model.lua b/hostname-model.lua index 87b3b5f..11aacae 100644 --- a/hostname-model.lua +++ b/hostname-model.lua @@ -2,18 +2,18 @@ module (..., package.seeall) fs = require("acf.fs") +require("modelfunctions") get = function (fqdn) - local f,n + local n if fqdn then - f = io.popen("/bin/hostname -f 2>/dev/null") - n = f:read("*a") - f:close() + n = modelfunctions.run_executable({"hostname", "-f"}) end if not n or n == "" then - f = io.popen("/bin/hostname") - n = f:read("*a") or "unknown" - f:close() + n = modelfunctions.run_executable({"hostname"}) + end + if not n or n == "" then + n = "unknown" end return cfe({value=n, label="Hostname"}) @@ -29,8 +29,7 @@ update_name = function(self, name) if success then fs.write_file("/etc/hostname", name.value.hostname.value) - local f = io.popen("/bin/hostname -F /etc/hostname") - f:close() + modelfunctions.run_executable({"hostname", "-F", "/etc/hostname"}) else name.errtxt = "Failed to set hostname" end |