packages/net/nginx/files/nginx.init
Peter Stadler 2401fd6db5 nginx: use /etc/nginx/nginx.conf enabling conf.d/
Instead of the default nginx.conf file this file is a small variant
without examples that enables the /etc/nginx/conf.d/ directory.

It will pull in all configuration files from the conf.d directory.
So, other packages can add their server parts in the conf.d directory
without modifying the main nginx.conf file (cf. #9860).

Changed also the default logging behavior:
	error_log stderr; # the init forwards it to logd
	access_log off;

See the updated documentation at:
https://openwrt.org/docs/guide-user/services/webserver/nginx

Signed-off-by: Peter Stadler <peter.stadler@student.uibk.ac.at>
2020-01-28 12:24:55 +01:00

59 lines
1.4 KiB
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=80
USE_PROCD=1
NGINX_UTIL="/usr/bin/nginx-util"
eval $("${NGINX_UTIL}" get_env)
start_service() {
[ -d /var/log/nginx ] || mkdir -p /var/log/nginx
[ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
${NGINX_UTIL} init_lan
procd_open_instance
NCPUS="$(grep -c '^processor\s*:' /proc/cpuinfo)"
procd_set_param command /usr/sbin/nginx -c "${NGINX_CONF}" \
-g "daemon off; worker_processes $NCPUS;"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param file "${LAN_LISTEN}" "${LAN_LISTEN}.default" \
"${NGINX_CONF}" "${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
[ "${LAN_SSL_LISTEN}" == "" ] \
|| procd_append_param file "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
"${LAN_SSL_LISTEN}" "${LAN_SSL_LISTEN}.default"
procd_set_param respawn
procd_close_instance
}
stop_service() {
rm -f "${LAN_LISTEN}" "${LAN_LISTEN}.default"
[ "${LAN_SSL_LISTEN}" == "" ] \
|| rm -f "${LAN_SSL_LISTEN}" "${LAN_SSL_LISTEN}.default"
}
service_triggers() {
procd_add_reload_interface_trigger loopback
procd_add_reload_interface_trigger lan
}
reload_service() {
[ -d /var/log/nginx ] || mkdir -p /var/log/nginx
[ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
${NGINX_UTIL} init_lan
procd_send_signal nginx
}
relog() {
[ -d /var/log/nginx ] || mkdir -p /var/log/nginx
procd_send_signal nginx '*' USR1
}
EXTRA_COMMANDS="relog"
EXTRA_HELP=" relog Reopen log files (without reloading)"