From 9e88c2e03968ffc8d0c930073662b2840936e67e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 20 Aug 2020 16:17:34 +0200 Subject: [PATCH] procd: procd.sh: make no assumptions about init script path Init scripts in /etc/init.d/ may be symlinks pointing elsewhere, so it is not safe to assume that the basename of the real path is existing. Instead of trying to reassemble the target path from the basename when setting up triggers, trust the result of readlink and fall back to `$initscript` which corresponds to `argv[0]` when readlink failed. This fixes reload trigger setup for init script symlinks that point to files with different base names. Signed-off-by: Jo-Philipp Wich --- package/system/procd/files/procd.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index 0f9405a222..45ee9e3184 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -300,11 +300,10 @@ _procd_add_interface_trigger() { } _procd_add_reload_interface_trigger() { - local script=$(readlink "$initscript") - local name=$(basename ${script:-$initscript}) + local script=$(readlink -f "$initscript") _procd_open_trigger - _procd_add_interface_trigger "interface.*" $1 /etc/init.d/$name reload + _procd_add_interface_trigger "interface.*" $1 "${script:-$initscript}" reload _procd_close_trigger } @@ -452,13 +451,12 @@ _procd_add_raw_trigger() { } _procd_add_reload_trigger() { - local script=$(readlink "$initscript") - local name=$(basename ${script:-$initscript}) + local script=$(readlink -f "$initscript") local file _procd_open_trigger for file in "$@"; do - _procd_add_config_trigger "config.change" "$file" /etc/init.d/$name reload + _procd_add_config_trigger "config.change" "$file" "${script:-$initscript}" reload done _procd_close_trigger } -- 2.30.2