summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/is.inc26
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/is.inc b/modules/is.inc
index 17e8a0d..3d623b8 100644
--- a/modules/is.inc
+++ b/modules/is.inc
@@ -1,6 +1,32 @@
#!/bin/ash
+# Check whether a value should be considered true/on. Checks for
+# 'on', 'yes', 'true', or 1, in either upper- or lowercase, but not
+# mixed case.
is_on() {
[ "$1" = "ON" ] || [ "$1" = "on" ] || [ "$1" = "YES" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] || [ "$1" = "TRUE" ] || [ "$1" -ne 0 ] 2>/dev/null || return 1
return 0
}
+
+# Checks whether we're running bwLehrpool/OpenSLX in debug mode.
+# Either $SLX_DEBUG is_on, or 'debug' is passed on KCL.
+is_debug() {
+ if [ -z "$SLX_PXE_SERVER_IP" ]; then
+ if [ -s /opt/openslx/config ]; then
+ . /opt/openslx/config
+ elif [ -s /etc/openslx ]; then
+ . /etc/openslx
+ fi
+ fi
+ # Replace function for future calls as this is const
+ if is_on "$SLX_DEBUG" || grep -qE '\bdebug\b' "/proc/cmdline"; then
+ is_debug() {
+ return 0
+ }
+ else
+ is_debug() {
+ return 1
+ }
+ fi
+ is_debug
+}