packages/net/nginx/files/nginx.init
Peter Stadler 3603f50fd5 nginx: enable ssl for all variants and remove nginx-util w/o ssl
Make the plain nginx version the same as nginx-ssl.
In a further change we will replace nginx by a dummy package,
depending on +nginx-ssl instead. This allows a smooth upgrade.

For nginx-util leave the ssl and the ssl-nopcre versions only.
For nginx-mod-luci remove the duplicate ssl version.
Replace the removed packages by dummies for a smooth upgrade.
The dummy packages will be removed after a transition period.

Additionally, enable the http2 module for nginx-ssl by default
and cleanup the nginx.init file.

Signed-off-by: Peter Stadler <peter.stadler@student.uibk.ac.at>
2020-07-25 17:36:28 +02:00

74 lines
1.4 KiB
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=80
USE_PROCD=1
G_OPTS="daemon off;"
NGINX_UTIL="/usr/bin/nginx-util"
eval $("${NGINX_UTIL}" get_env)
CONF=""
nginx_init() {
[ -z "${CONF}" ] || return # already called.
[ -d /var/log/nginx ] || mkdir -p /var/log/nginx
[ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
${NGINX_UTIL} init_lan
CONF="${NGINX_CONF}"
local message
message="$(/usr/sbin/nginx -t -c "${CONF}" -g "${G_OPTS}" 2>&1)" ||
{
echo -e "${message}" | logger -t "nginx_init" -p "daemon.err"
logger -s -t "nginx_init" -p "daemon.err" "NOT using conf file!"
echo "show config to be used by: nginx -T -c '${CONF}'" >&2
exit 1
}
logger -t "nginx_init" -p "daemon.info" "using ${CONF} (the test is ok)"
}
start_service() {
nginx_init
procd_open_instance
procd_set_param command /usr/sbin/nginx -c "${CONF}" -g "${G_OPTS}"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param file "${CONF}" "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
"${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
procd_set_param respawn
procd_close_instance
}
service_triggers() {
procd_add_reload_interface_trigger loopback
procd_add_reload_interface_trigger lan
}
reload_service() {
nginx_init
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)"