From 5ca33b525b56f0e255e2e3bb35441b78b23aee4a Mon Sep 17 00:00:00 2001 From: Kerin Millar Date: Wed, 12 Jun 2024 06:41:22 +0100 Subject: Add the from_unit() function The function determines whether the current shell is a subprocess of a systemd unit that handles a service, socket, mount point or swap device, per systemd.exec(5). Signed-off-by: Kerin Millar --- functions.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/functions.sh b/functions.sh index 605aa48..7d146c8 100644 --- a/functions.sh +++ b/functions.sh @@ -324,6 +324,15 @@ from_runscript() has_openrc && test "${RC_OPENRC_PID}" } +# +# Determines whether the current shell is a subprocess of a systemd unit that +# handles a service, socket, mount point or swap device, per systemd.exec(5). +# +from_unit() +{ + has_systemd && test "${SYSTEMD_EXEC_PID}" && test "${INVOCATION_ID}" +} + # # Determines whether the kernel cmdline contains the specified parameter as a # component of a comma-separated list specified in the format of gentoo=. -- cgit v1.2.3-65-gdbad