mirror of
https://github.com/openwrt/packages.git
synced 2025-12-21 23:34:31 +04:00
nginx: update init script to publish services over mdns
Update nginx init script to announce http related services over mdns. Signed-off-by: Mohd Husaam Mehdi <husaam.mehdi@iopsys.eu> [ bump PKG release, improve commit description ] Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
committed by
Christian Marangi
parent
40cfff8fe9
commit
d7e86e79d9
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=nginx
|
PKG_NAME:=nginx
|
||||||
PKG_VERSION:=1.26.1
|
PKG_VERSION:=1.26.1
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=3
|
||||||
|
|
||||||
PKG_SOURCE:=nginx-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=nginx-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=https://nginx.org/download/
|
PKG_SOURCE_URL:=https://nginx.org/download/
|
||||||
|
|||||||
@@ -75,6 +75,53 @@ nginx_init() {
|
|||||||
logger -t "nginx_init" -p "daemon.info" "using ${CONF} (the test is ok)"
|
logger -t "nginx_init" -p "daemon.info" "using ${CONF} (the test is ok)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_mdns() {
|
||||||
|
local cfg="$1"
|
||||||
|
local port enabled service
|
||||||
|
|
||||||
|
config_get enabled "$cfg" enabled
|
||||||
|
config_get port "$cfg" listen
|
||||||
|
|
||||||
|
port=$(echo "$port" | head -n1 | awk '{print $1;}')
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$enabled" != "0" ] && [ "$enabled" != "false" ] && [ -n "$port" ]; then
|
||||||
|
case "$port" in
|
||||||
|
"80")
|
||||||
|
service="http"
|
||||||
|
;;
|
||||||
|
"8080")
|
||||||
|
service="http-alt"
|
||||||
|
;;
|
||||||
|
"443")
|
||||||
|
service="https"
|
||||||
|
;;
|
||||||
|
"8443")
|
||||||
|
service="pcsync-https"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
service="custom-http-$port"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
procd_add_mdns_service "$service" "tcp" "$port" "daemon=nginx"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_mdns() {
|
||||||
|
local mdns="$(uci -q get nginx.global.mdns)"
|
||||||
|
|
||||||
|
if [ "$mdns" = "1" ] || [ "$mdns" = "true" ]; then
|
||||||
|
procd_open_data
|
||||||
|
json_add_object "mdns"
|
||||||
|
|
||||||
|
config_load nginx
|
||||||
|
config_foreach add_mdns server
|
||||||
|
|
||||||
|
json_close_object
|
||||||
|
procd_close_data
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
nginx_init
|
nginx_init
|
||||||
@@ -86,6 +133,9 @@ start_service() {
|
|||||||
procd_set_param file "${CONF}" "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
|
procd_set_param file "${CONF}" "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
|
||||||
"${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
|
"${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
|
|
||||||
|
configure_mdns
|
||||||
|
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user