summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mhavela@inspiron.(none)>2009-09-04 10:30:47 +0200
committerMika Havela <mhavela@inspiron.(none)>2009-09-04 10:30:47 +0200
commit1bccca67e767e8eb7062738375fa597c84a95f7d (patch)
tree9c9d896529e9a966d796f08b29a5abab37d277fa
parentb61b3fbde769c1bd36b478048b03e551b8cdafa3 (diff)
downloadacf-alpine-baselayout-1bccca67e767e8eb7062738375fa597c84a95f7d.tar.bz2
acf-alpine-baselayout-1bccca67e767e8eb7062738375fa597c84a95f7d.tar.xz
Output 'apk version --index' in general health.
If 'apk verions --index' fails to give output, we fallback to displaying /etc/alpine-release. Last option is to display 'Unknown' (if neither of the above works).
-rw-r--r--health-model.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/health-model.lua b/health-model.lua
index f8a0444..f505ea7 100644
--- a/health-model.lua
+++ b/health-model.lua
@@ -14,6 +14,14 @@ local function querycmd ( cmdline )
return cmd_result
end
+local function indexversion ( )
+ local cmd = io.popen( "/sbin/apk version --index 2>/dev/null" )
+ local cmd_result = cmd:read("*a")
+ if cmd_result == "" then cmd_result = nil end
+ cmd:close()
+ return cmd_result
+end
+
local function diskfree ( media )
if not (media) then media = "" end
local cmd = io.popen( "df -h " .. format.escapespecialcharacters(media) )
@@ -35,7 +43,8 @@ get_system = function (self)
local system = {}
system.uptime = cfe({ value=querycmd("/usr/bin/uptime"), label="Uptime" })
system.date = cfe({ value=querycmd("/bin/date"), label="Date" })
- system.version = cfe({ value=fs.read_file("/etc/alpine-release") or "Unknown", label="Version" })
+ local indexver = indexversion()
+ system.version = cfe({ value=indexver or fs.read_file("/etc/alpine-release") or "Unknown", label="Version" })
system.timezone = cfe({ value=date.what_tz(), label="Time Zone" })
system.uname = cfe({ value=querycmd("/bin/uname -a"), label="UName" })
system.memory = cfe({ value=querycmd("/usr/bin/free"), label="Memory usage" })