1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2015 OpenWrt.org
10 NGINX_UTIL
="/usr/bin/nginx-util"
12 eval $
("${NGINX_UTIL}" get_env
)
18 [ -z "${CONF}" ] ||
return # already called.
20 [ -d /var
/log
/nginx
] || mkdir
-p /var
/log
/nginx
21 [ -d /var
/lib
/nginx
] || mkdir
-p /var
/lib
/nginx
23 rm -f "$(readlink "${UCI_CONF}")"
24 ${NGINX_UTIL} init_lan
26 if [ -e "${UCI_CONF}" ]
27 then CONF
="${UCI_CONF}"
28 else CONF
="${NGINX_CONF}"
32 message
="$(/usr/sbin/nginx -t -c "${CONF}" -g "${G_OPTS}" 2>&1)" ||
34 echo -e "${message}" | logger
-t "nginx_init" -p "daemon.err"
35 logger
-s -t "nginx_init" -p "daemon.err" "NOT using conf file!"
36 echo "show config to be used by: nginx -T -c '${CONF}'" >&2
40 logger
-t "nginx_init" -p "daemon.info" "using ${CONF} (the test is ok)"
48 procd_set_param
command /usr
/sbin
/nginx
-c "${CONF}" -g "${G_OPTS}"
49 procd_set_param stdout
1
50 procd_set_param stderr
1
51 procd_set_param
file "${CONF}" "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
52 "${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
53 procd_set_param respawn
61 if [ "$(cat "/proc
/$
(cat "/var/run/nginx.pid")/cmdline
")" = \
62 "nginx: master process /usr/sbin/nginx -c ${CONF} -g ${G_OPTS}" ]
63 then procd_send_signal nginx
70 procd_add_raw_trigger acme.renew
5000 /etc
/init.d
/nginx reload
74 extra_command
"relog" "Reopen log files (without reloading)"
76 [ -d /var
/log
/nginx
] || mkdir
-p /var
/log
/nginx
77 procd_send_signal nginx
'*' USR1