check_if_service_exists() function

This commit is contained in:
myvesta 2021-12-12 16:28:16 +01:00 committed by GitHub
parent 591bd21615
commit c7b872b778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}