From c7b872b7787c38b89cc2683b2abf369bb920c024 Mon Sep 17 00:00:00 2001 From: myvesta <38690722+myvesta@users.noreply.github.com> Date: Sun, 12 Dec 2021 16:28:16 +0100 Subject: [PATCH] check_if_service_exists() function --- func/main.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/func/main.sh b/func/main.sh index a92bb59a..69737c72 100644 --- a/func/main.sh +++ b/func/main.sh @@ -1114,3 +1114,11 @@ send_email_to_admin() { fi echo "$2" | $SENDMAIL -s "$1" "$email" 'yes' } + +check_if_service_exists() { + if [ $(systemctl list-units --all -t service --full --no-legend | grep -c "$1") -gt 0 ]; then + echo "1" + else + echo "0" + fi +}