This commit is contained in:
Richard Yu 2024-05-01 07:11:51 +03:00 committed by GitHub
commit 60df939219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -1,17 +1,20 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
[ -z "${CONFIG_SECTION_ID}" ] && exit 1
export -n CONFIG_SECTION_ID
(
. /usr/share/libubox/jshn.sh
json_init
json_add_string ip "$1"
json_add_int port "$2"
json_add_int inner_port "$4"
json_add_string protocol "$5"
json_dump > /var/run/natmap/$PPID.json
json_dump > "/var/run/natmap/${CONFIG_SECTION_ID}.json"
)
[ -n "${NOTIFY_SCRIPT}" ] && {
export -n NOTIFY_SCRIPT
exec "${NOTIFY_SCRIPT}" "$@"
}
. /lib/functions.sh
NOTIFY_SCRIPT="$(uci_get natmap "${CONFIG_SECTION_ID}" notify_script)"
[ "$?" -eq 0 ] && [ -n "${NOTIFY_SCRIPT}" ] && exec "${NOTIFY_SCRIPT}" "$@"

View File

@ -61,7 +61,7 @@ natmap_instance() {
[ -n "${forward_target}" ] && procd_append_param command -t "$forward_target" -p "$forward_port"
[ -n "${notify_script}" ] && procd_set_param env "NOTIFY_SCRIPT=${notify_script}"
procd_set_param env "CONFIG_SECTION_ID=$1"
procd_append_param command -e /usr/lib/natmap/update.sh
procd_set_param respawn