procd: support generic mount triggers and clean up
Allow init scripts to trigger free-form actions by exposing procd_add_action_mount_trigger. Clean up mount trigger wrappers while at it to reduce code duplication. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
b21bc3479d
commit
6d76ec3872
1 changed files with 9 additions and 11 deletions
|
@ -363,14 +363,15 @@ _procd_add_mount_trigger() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_procd_add_action_mount_trigger() {
|
_procd_add_action_mount_trigger() {
|
||||||
|
local action="$1"
|
||||||
|
shift
|
||||||
|
local mountpoints="$(procd_get_mountpoints "$@")"
|
||||||
|
[ "${mountpoints//[[:space:]]}" ] || return 0
|
||||||
local script=$(readlink "$initscript")
|
local script=$(readlink "$initscript")
|
||||||
local name=$(basename ${script:-$initscript})
|
local name=$(basename ${script:-$initscript})
|
||||||
local action="$1"
|
|
||||||
local mpath
|
|
||||||
shift
|
|
||||||
|
|
||||||
_procd_open_trigger
|
_procd_open_trigger
|
||||||
_procd_add_mount_trigger mount.add $action "$@"
|
_procd_add_mount_trigger mount.add $action "$mountpoints"
|
||||||
_procd_close_trigger
|
_procd_close_trigger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +385,7 @@ procd_get_mountpoints() {
|
||||||
target="${target%%/}/"
|
target="${target%%/}/"
|
||||||
[ "$path" != "${path##$target}" ] && echo "${target%%/}"
|
[ "$path" != "${path##$target}" ] && echo "${target%%/}"
|
||||||
}
|
}
|
||||||
|
local mpath
|
||||||
config_load fstab
|
config_load fstab
|
||||||
for mpath in "$@"; do
|
for mpath in "$@"; do
|
||||||
config_foreach __procd_check_mount mount "$mpath"
|
config_foreach __procd_check_mount mount "$mpath"
|
||||||
|
@ -393,15 +394,11 @@ procd_get_mountpoints() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_procd_add_restart_mount_trigger() {
|
_procd_add_restart_mount_trigger() {
|
||||||
local mountpoints="$(procd_get_mountpoints "$@")"
|
_procd_add_action_mount_trigger restart "$@"
|
||||||
[ "${mountpoints//[[:space:]]}" ] &&
|
|
||||||
_procd_add_action_mount_trigger restart $mountpoints
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_procd_add_reload_mount_trigger() {
|
_procd_add_reload_mount_trigger() {
|
||||||
local mountpoints="$(procd_get_mountpoints "$@")"
|
_procd_add_action_mount_trigger reload "$@"
|
||||||
[ "${mountpoints//[[:space:]]}" ] &&
|
|
||||||
_procd_add_action_mount_trigger reload $mountpoints
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_procd_add_raw_trigger() {
|
_procd_add_raw_trigger() {
|
||||||
|
@ -638,6 +635,7 @@ _procd_wrapper \
|
||||||
procd_add_mount_trigger \
|
procd_add_mount_trigger \
|
||||||
procd_add_reload_trigger \
|
procd_add_reload_trigger \
|
||||||
procd_add_reload_interface_trigger \
|
procd_add_reload_interface_trigger \
|
||||||
|
procd_add_action_mount_trigger \
|
||||||
procd_add_reload_mount_trigger \
|
procd_add_reload_mount_trigger \
|
||||||
procd_add_restart_mount_trigger \
|
procd_add_restart_mount_trigger \
|
||||||
procd_open_trigger \
|
procd_open_trigger \
|
||||||
|
|
Loading…
Reference in a new issue