diff options
author | 2024-06-12 06:41:22 +0100 | |
---|---|---|
committer | 2024-06-14 01:27:44 +0100 | |
commit | 5ca33b525b56f0e255e2e3bb35441b78b23aee4a (patch) | |
tree | 6d09b2376a54a078bbc5f292c3def016ec5aa62f | |
parent | Add the from_runscript() function (diff) | |
download | gentoo-functions-5ca33b525b56f0e255e2e3bb35441b78b23aee4a.tar.gz gentoo-functions-5ca33b525b56f0e255e2e3bb35441b78b23aee4a.tar.bz2 gentoo-functions-5ca33b525b56f0e255e2e3bb35441b78b23aee4a.zip |
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 <kfm@plushkava.net>
-rw-r--r-- | functions.sh | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/functions.sh b/functions.sh index 605aa48..7d146c8 100644 --- a/functions.sh +++ b/functions.sh @@ -325,6 +325,15 @@ from_runscript() } # +# 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=<list>. # |