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 <jo@mein.io>
}
_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
}
}
_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
}