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.

58 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=80
  4. USE_PROCD=1
  5. NGINX_UTIL="/usr/bin/nginx-util"
  6. eval $("${NGINX_UTIL}" get_env)
  7. start_service() {
  8. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  9. [ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
  10. ${NGINX_UTIL} init_lan
  11. procd_open_instance
  12. procd_set_param command /usr/sbin/nginx -c "${NGINX_CONF}" \
  13. -g "daemon off;"
  14. procd_set_param stdout 1
  15. procd_set_param stderr 1
  16. procd_set_param file "${LAN_LISTEN}" "${LAN_LISTEN}.default" \
  17. "${NGINX_CONF}" "${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
  18. [ "${LAN_SSL_LISTEN}" == "" ] \
  19. || procd_append_param file "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
  20. "${LAN_SSL_LISTEN}" "${LAN_SSL_LISTEN}.default"
  21. procd_set_param respawn
  22. procd_close_instance
  23. }
  24. stop_service() {
  25. rm -f "${LAN_LISTEN}" "${LAN_LISTEN}.default"
  26. [ "${LAN_SSL_LISTEN}" == "" ] \
  27. || rm -f "${LAN_SSL_LISTEN}" "${LAN_SSL_LISTEN}.default"
  28. }
  29. service_triggers() {
  30. procd_add_reload_interface_trigger loopback
  31. procd_add_reload_interface_trigger lan
  32. }
  33. reload_service() {
  34. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  35. [ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
  36. ${NGINX_UTIL} init_lan
  37. procd_send_signal nginx
  38. }
  39. relog() {
  40. [ -d /var/log/nginx ] || mkdir -p /var/log/nginx
  41. procd_send_signal nginx '*' USR1
  42. }
  43. EXTRA_COMMANDS="relog"
  44. EXTRA_HELP=" relog Reopen log files (without reloading)"