packages/net/nginx/files-luci-support/60_nginx-luci-support
Christian Marangi 65a676ed56
nginx: introduce support for dynamic modules
Start building sub package that provide dynamic modules.

Each module needs to be loaded using load_modules.
Refer to nginx documentation on how to use this.

This should result in lower memory usage as only used module are loaded.

Also fix the uci-default scripts to add the required ubus module for
luci module.

-fvisibility=hidden is needed to be dropped to correctly support loading
dynamic modules.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2023-04-27 06:14:57 +02:00

47 lines
1.1 KiB
Bash

#!/bin/sh
if nginx -V 2>&1 | grep -q ubus && [ -f /usr/lib/nginx/modules/ngx_http_ubus_module.so ]; then
if [ -z "$(cat /etc/nginx/conf.d/luci.locations | grep ubus)" ]; then
cat <<EOT >> /etc/nginx/conf.d/luci.locations
location /ubus {
ubus_interpreter;
ubus_socket_path /var/run/ubus/ubus.sock;
ubus_parallel_req 2;
}
EOT
fi
if [ ! -f "/etc/nginx/module.d/luci.module" ]; then
cat <<EOT >> /etc/nginx/module.d/luci.module
load_module /usr/lib/nginx/modules/ngx_http_ubus_module.so;
EOT
fi
fi
grep -q /var/run/ubus.sock /etc/nginx/conf.d/luci.locations &&
sed -i 's#/var/run/ubus.sock#/var/run/ubus/ubus.sock#' /etc/nginx/conf.d/luci.locations
if [ -x /etc/init.d/uhttpd ]; then
/etc/init.d/uhttpd disable
if [ -n "$(pgrep uhttpd)" ]; then
/etc/init.d/uhttpd stop
fi
fi
/etc/init.d/nginx enable
if [ -n "$(pgrep nginx)" ]; then
/etc/init.d/nginx restart
else
/etc/init.d/nginx start
fi
/etc/init.d/uwsgi enable
if [ -n "$(pgrep uwsgi)" ]; then
/etc/init.d/uwsgi restart
else
/etc/init.d/uwsgi start
fi
exit 0