nginx: autoload dynamic modules
[feed/packages.git] / net / nginx / files-luci-support / 60_nginx-luci-support
1 #!/bin/sh
2
3 if nginx -V 2>&1 | grep -q ubus && [ -f /usr/lib/nginx/modules/ngx_http_ubus_module.so ]; then
4 if [ -z "$(cat /etc/nginx/conf.d/luci.locations | grep ubus)" ]; then
5 cat <<EOT >> /etc/nginx/conf.d/luci.locations
6
7 location /ubus {
8 ubus_interpreter;
9 ubus_socket_path /var/run/ubus/ubus.sock;
10 ubus_parallel_req 2;
11 }
12 EOT
13 fi
14
15 if [ ! -f "/etc/nginx/module.d/ngx_http_ubus.module" ]; then
16 cat <<EOT > /etc/nginx/module.d/ngx_http_ubus.module
17 load_module /usr/lib/nginx/modules/ngx_http_ubus_module.so;
18 EOT
19 fi
20 fi
21
22 grep -q /var/run/ubus.sock /etc/nginx/conf.d/luci.locations &&
23 sed -i 's#/var/run/ubus.sock#/var/run/ubus/ubus.sock#' /etc/nginx/conf.d/luci.locations
24
25 if [ -x /etc/init.d/uhttpd ]; then
26 /etc/init.d/uhttpd disable
27 if [ -n "$(pgrep uhttpd)" ]; then
28 /etc/init.d/uhttpd stop
29 fi
30 fi
31
32 /etc/init.d/nginx enable
33 if [ -n "$(pgrep nginx)" ]; then
34 /etc/init.d/nginx restart
35 else
36 /etc/init.d/nginx start
37 fi
38
39 /etc/init.d/uwsgi enable
40 if [ -n "$(pgrep uwsgi)" ]; then
41 /etc/init.d/uwsgi restart
42 else
43 /etc/init.d/uwsgi start
44 fi
45
46
47 exit 0