From f575350b7d48f5d879b540ccf597c518cd8ec389 Mon Sep 17 00:00:00 2001 From: Beginner <70857188+Beginner-Go@users.noreply.github.com> Date: Fri, 13 Aug 2021 23:17:18 +0800 Subject: [PATCH] procd: update to git HEAD (#7670) * procd: update to git HEAD 2dcefbd jail: add support for cgroup devices as in OCI run-time spec Signed-off-by: Daniel Golle * procd: update to git HEAD 0ee73b2 uxc: implement support for rootfs overlay in containers b0a8ea1 jail: do not hack /etc/resolv.conf on container rootfs 92aba53 jail: increase max additional env records to 64 15997e6 jail: allow rootfs to be a symbolic link 0114c6f jail: open() extroot folder before mounting ed96eda uxc: check for required blockd mounts Signed-off-by: Daniel Golle * procd: update to git HEAD 0545905 jail: make use of realpath() for rootfs and overlaydir Signed-off-by: Daniel Golle * procd: update to git HEAD 9bd1b7f jail: refactor directory handling for rootfs and overlaydir Signed-off-by: Daniel Golle * procd: update to git HEAD 772292e uxc: don't restart containers when mount shows up 3a9d910 uxc: resolve volume UUIDs by name of UCI fstab section Signed-off-by: Daniel Golle * procd: update to git HEAD f26233e watchdog: Add an info message if the watchdog reset the system Signed-off-by: Hauke Mehrtens * procd: update to git HEAD Fix build on glibc targets and address a bunch of compiler warnings. 93fc089 jail: cgroups-bpf: don't use sys/reg.h when building with glibc 548d057 jail: don't ignore return value of seteuid() 220b716 jail: ignore return value when creating default /dev symlinks 78d5baa hotplug-dispatch: don't ignore asprintf() return value 736aee5 uxc: always handle asprintf() return value 2b20456 hotplug-dispatch: replace wrongly used assert() bfc86a2 jail: cgroups: replace wrongly used assert() 516bdf2 jail: don't ignore return value of write() Signed-off-by: Daniel Golle * procd: update to git HEAD and add new script helpers e10de28 jail: cgroups-bpf: fix compile with musl 1.2 f5d9b14 hotplug-dispatch: fix rare memory leaks in error paths Add new init script helpers: procd_add_start_mount_trigger procd_add_reload_mount_trigger procd_get_mountpoints Both trigger helpers expect a list of paths which are checked against the mount targets configured in /etc/config/fstab and a trigger for all mountpoints covered by the list of paths is setup. procd_get_mountpoints is useful to find out if and which mountpoints are covered by a list of paths. Example: DATADIRS="/mnt/data/foo /mnt/data/bar /etc/foo/baz /var/lib/doe" start_service() { [ "$_BOOT" = "1" ] && [ "$(procd_get_mountpoints $DATADIRS)" ] && return 0 procd_open_instance # ... procd_close_instance } boot() { _BOOT=1 start } service_triggers() { procd_add_start_mount_trigger $DATADIRS } Signed-off-by: Daniel Golle * procd: change procd_add_start_mount_trigger to do restart Change procd_add_start_mount_trigger to procd_add_restart_mount_trigger and make it call 'restart' instead of 'start'. This is more useful as it allows to handle both cases, intial start of a services as well as restarting services. Calling 'restart' on a service which has not yet been started has the same result as calling 'start'. Signed-off-by: Daniel Golle * procd: update to git HEAD 9f233f5 system: make rootfs type accessible through board call Signed-off-by: Daniel Golle Co-authored-by: Daniel Golle Co-authored-by: Hauke Mehrtens --- package/system/procd/Makefile | 8 +-- package/system/procd/files/procd.sh | 75 +++++++++++++++++++++++++++++ package/system/procd/files/uxc.init | 4 ++ 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index 2b0ea6d11..ccd0a9c75 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git -PKG_SOURCE_DATE:=2021-05-05 -PKG_SOURCE_VERSION:=021ece84de430fca988acd6934f6046ea59d8c37 -PKG_MIRROR_HASH:=edbe464cadbae000f4a48a6f1e6a0f5d27ae3ad521e308205252ad89639b6f9d +PKG_SOURCE_DATE:=2021-08-13 +PKG_SOURCE_VERSION:=9f233f555f80d1c416656c04ab81d19edc738f07 +PKG_MIRROR_HASH:=01cdadba9e3a8848342f40383ff61cdc91516c9198790ca49dcc6837cdd83351 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 @@ -90,7 +90,7 @@ endef define Package/uxc SECTION:=base CATEGORY:=Base system - DEPENDS:=+procd-ujail +libubus +libubox +libblobmsg-json + DEPENDS:=+procd-ujail +libubus +libubox +libblobmsg-json +blockd TITLE:=OpenWrt container management MAINTAINER:=Daniel Golle endef diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index 2028c95e4..3be496fbb 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -320,6 +320,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_restart_mount_trigger() { + _procd_add_action_mount_trigger restart $(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" @@ -551,8 +623,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_restart_mount_trigger \ procd_open_trigger \ procd_close_trigger \ procd_open_instance \ diff --git a/package/system/procd/files/uxc.init b/package/system/procd/files/uxc.init index 035c8b0b9..1e75b796f 100644 --- a/package/system/procd/files/uxc.init +++ b/package/system/procd/files/uxc.init @@ -16,3 +16,7 @@ boot() { __BOOT_UXC=1 start } + +service_triggers() { + procd_add_raw_trigger "mount.add" 3000 /etc/init.d/uxc boot +}