summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-06-12 06:41:22 +0100
committerKerin Millar <kfm@plushkava.net>2024-06-14 01:27:44 +0100
commit5ca33b525b56f0e255e2e3bb35441b78b23aee4a (patch)
tree6d09b2376a54a078bbc5f292c3def016ec5aa62f
parentAdd the from_runscript() function (diff)
downloadgentoo-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.sh9
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>.
#