From d11323d55db4bb362e15b98af09d5515bae2bf82 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Sat, 13 Aug 2022 14:25:55 +0200 Subject: [PATCH] refactor(moonraker.sh): allow to ignore moonraker clients which have "moonraker" in their own name Signed-off-by: Dominik Willner --- scripts/moonraker.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/moonraker.sh b/scripts/moonraker.sh index 45af1be..0e8cfe1 100644 --- a/scripts/moonraker.sh +++ b/scripts/moonraker.sh @@ -15,9 +15,24 @@ set -e #================ INSTALL MOONRAKER ================# #===================================================# +### +# this function detects all installed moonraker +# systemd instances and returns their absolute path function moonraker_systemd() { local services - services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/moonraker(-[0-9a-zA-Z]+)?.service" | grep -v "moonraker-obico" | sort) + local blacklist + local ignore + local match + + ### + # any moonraker client that uses "moonraker" in its own name must be blacklisted using + # this variable, otherwise they will be falsely recognized as moonraker instances + blacklist="obico" + + ignore="${SYSTEMD}/moonraker-(${blacklist}).service" + match="${SYSTEMD}/moonraker(-[0-9a-zA-Z]+)?.service" + + services=$(find "${SYSTEMD}" -maxdepth 1 -regextype awk ! -regex "${ignore}" -regex "${match}" | sort) echo "${services}" }