diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-08-23 09:07:23 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-08-23 09:18:04 +0200 |
commit | 214146c6f298e593695c29b8c04a418dac914040 (patch) | |
tree | 6e87d7ee4acccecf7e668ae70c61bd666c1a8695 /package/network/services/uhttpd/files/uhttpd.init | |
parent | 7e73e9128f6a63b9198c88eea97c267810447be4 (diff) | |
download | upstream-214146c6f298e593695c29b8c04a418dac914040.tar.gz upstream-214146c6f298e593695c29b8c04a418dac914040.tar.bz2 upstream-214146c6f298e593695c29b8c04a418dac914040.zip |
uhttpd: support multiple Lua prefixes
Update to latest git HEAD in order to support configuring multiple
concurrent Lua prefixes in a single uhttpd instance:
b741dec lua: support multiple Lua prefixes
Additionally rework the init script and update the default configuration
example to treat the lua_prefix option as key=value uci list, similar to
the interpreter extension mapping. Support for the old "option lua_prefix"
plus "option lua_handler" notation is still present.
Finally drop the sed postinstall hack in uhttpd-mod-lua to avoid mangling
files belonging to other packages. Since Lua prefixes have precedence
over CGI prefixes, simply register `/cgi-bin/luci` as Lua handler which
will only become active if both luci-base and uhttpd-mod-lua is installed.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'package/network/services/uhttpd/files/uhttpd.init')
-rwxr-xr-x | package/network/services/uhttpd/files/uhttpd.init | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/package/network/services/uhttpd/files/uhttpd.init b/package/network/services/uhttpd/files/uhttpd.init index 47270bcc15..dc496b3e28 100755 --- a/package/network/services/uhttpd/files/uhttpd.init +++ b/package/network/services/uhttpd/files/uhttpd.init @@ -74,6 +74,18 @@ create_httpauth() { haveauth=1 } +append_lua_prefix() { + local v="$1" + local prefix="${v%%=*}" + local handler="${v#*=}" + + if [ "$prefix" != "$handler" ] && [ -n "$prefix" ] && [ -f "$handler" ]; then + procd_append_param command -l "$prefix" -L "$handler" + else + echo "Skipping invalid Lua prefix \"$v\"" >&2 + fi +} + start_instance() { UHTTPD_CERT="" @@ -105,10 +117,16 @@ start_instance() append_arg "$cfg" config "-c" append_arg "$cfg" cgi_prefix "-x" [ -f /usr/lib/uhttpd_lua.so ] && { - config_get handler "$cfg" lua_handler - [ -f "$handler" ] && append_arg "$cfg" lua_prefix "-l" && { - procd_append_param command "-L" "$handler" - } + local len + config_get len "$cfg" lua_prefix_LENGTH + + if [ -n "$len" ]; then + config_list_foreach "$cfg" lua_prefix append_lua_prefix + else + config_get prefix "$cfg" lua_prefix + config_get handler "$cfg" lua_handler + append_lua_prefix "$prefix=$handler" + fi } [ -f /usr/lib/uhttpd_ubus.so ] && { append_arg "$cfg" ubus_prefix "-u" |