SOLVED: Luci app ubus access

Struggling to find up-to-date documentation on pulling information from ubus inside of the luci app.

Is this still valid: ? I can't make it work inside the lua shell.

I've searched the luci repo for ubus and found two ways it's being used by current code:


In ash I do: echo "$(ubus call service list "{\"name\": \"${packageName}\"}" | jsonfilter -l1 -e "@['${packageName}']['instances']['status']['data']['status']")", how do I do the same in lua/luci app?


Solution: do not use local for variable declarations in lua console.

New URL:

1 Like

Both wiki approach and using luci.util.ubus work. I ended up doing this:

local util = require "luci.util"
local serviceName = "myService"
local status = util.ubus('service', 'list', { name = serviceName })[serviceName]['instances']['status']['data']['status'] or "Stopped"