diff options
Diffstat (limited to 'package/system/procd/files/procd.sh')
-rw-r--r-- | package/system/procd/files/procd.sh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index d86b7219da..de30c76878 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -329,6 +329,78 @@ _procd_add_config_trigger() { json_close_array } +_procd_add_mount_trigger() { + json_add_array + _procd_add_array_data "$1" + local action="$2" + local multi=0 + shift ; shift + + json_add_array + _procd_add_array_data "if" + + if [ "$2" ]; then + json_add_array + _procd_add_array_data "or" + multi=1 + fi + + while [ "$1" ]; do + json_add_array + _procd_add_array_data "eq" "target" "$1" + shift + json_close_array + done + + [ $multi = 1 ] && json_close_array + + json_add_array + _procd_add_array_data "run_script" /etc/init.d/$name $action + json_close_array + + json_close_array + _procd_add_timeout + json_close_array +} + +_procd_add_action_mount_trigger() { + local script=$(readlink "$initscript") + local name=$(basename ${script:-$initscript}) + local action="$1" + local mpath + shift + + _procd_open_trigger + _procd_add_mount_trigger mount.add $action "$@" + _procd_close_trigger +} + +procd_get_mountpoints() { + ( + __procd_check_mount() { + local cfg="$1" + local path="${2%%/}/" + local target + config_get target "$cfg" target + target="${target%%/}/" + [ "$path" != "${path##$target}" ] && echo "${target%%/}" + } + + config_load fstab + for mpath in "$@"; do + config_foreach __procd_check_mount mount "$mpath" + done + ) | sort -u +} + +_procd_add_start_mount_trigger() { + _procd_add_action_mount_trigger start $(procd_get_mountpoints "$@") +} + +_procd_add_reload_mount_trigger() { + _procd_add_action_mount_trigger reload $(procd_get_mountpoints "$@") +} + _procd_add_raw_trigger() { json_add_array _procd_add_array_data "$1" @@ -560,8 +632,11 @@ _procd_wrapper \ procd_add_raw_trigger \ procd_add_config_trigger \ procd_add_interface_trigger \ + procd_add_mount_trigger \ procd_add_reload_trigger \ procd_add_reload_interface_trigger \ + procd_add_reload_mount_trigger \ + procd_add_start_mount_trigger \ procd_open_trigger \ procd_close_trigger \ procd_open_instance \ |