aboutsummaryrefslogtreecommitdiff
path: root/net/nginx/files-luci-support/60_nginx-luci-support
blob: 4967246eebbecfa5e889291d67d01cf9ad4ffa51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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/ngx_http_ubus.module" ]; then
		cat <<EOT > /etc/nginx/module.d/ngx_http_ubus.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