You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=80
  4. USE_PROCD=1
  5. G_OPTS="daemon off;"
  6. NGINX_UTIL="/usr/bin/nginx-util"
  7. eval $("${NGINX_UTIL}" get_env)
  8. CONF=""
  9. nginx_init() {
  10. [ -z "${CONF}" ] || return # already called.
  11. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  12. [ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
  13. ${NGINX_UTIL} init_lan
  14. CONF="${NGINX_CONF}"
  15. local message
  16. message="$(/usr/sbin/nginx -t -c "${CONF}" -g "${G_OPTS}" 2>&1)" ||
  17. {
  18. echo -e "${message}" | logger -t "nginx_init" -p "daemon.err"
  19. logger -s -t "nginx_init" -p "daemon.err" "NOT using conf file!"
  20. echo "show config to be used by: nginx -T -c '${CONF}'" >&2
  21. exit 1
  22. }
  23. logger -t "nginx_init" -p "daemon.info" "using ${CONF} (the test is ok)"
  24. }
  25. start_service() {
  26. nginx_init
  27. procd_open_instance
  28. procd_set_param command /usr/sbin/nginx -c "${CONF}" -g "${G_OPTS}"
  29. procd_set_param stdout 1
  30. procd_set_param stderr 1
  31. procd_set_param file "${CONF}" "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
  32. "${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
  33. procd_set_param respawn
  34. procd_close_instance
  35. }
  36. service_triggers() {
  37. procd_add_reload_interface_trigger loopback
  38. procd_add_reload_interface_trigger lan
  39. }
  40. reload_service() {
  41. nginx_init
  42. procd_send_signal nginx
  43. }
  44. relog() {
  45. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  46. procd_send_signal nginx '*' USR1
  47. }
  48. EXTRA_COMMANDS="relog"
  49. EXTRA_HELP=" relog Reopen log files (without reloading)"