Skip to content

Commit

Permalink
Use Bash tests
Browse files Browse the repository at this point in the history
  • Loading branch information
melmorabity committed Aug 21, 2017
1 parent 768e416 commit 8f4909c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions check_systemd_service.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (C) 2016 Mohamed El Morabity <[email protected]>
# Copyright © 2016, 2017 Mohamed El Morabity <[email protected]>
#
# This module is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand All @@ -19,8 +19,8 @@ PLUGINDIR=$(dirname $0)
. $PLUGINDIR/utils.sh


if [ $# -ne 1 ]; then
echo "Usage: ${0##*/} <service name>" >&2
if [[ $# -ne 1 ]]; then
echo "Usage: ${0##*/} <service name>"
exit $STATE_UNKNOWN
fi

Expand All @@ -29,19 +29,19 @@ service=$1

status=$(systemctl is-enabled $service 2>/dev/null)
r=$?
if [ -z "$status" ]; then
if [[ -z "$status" ]]; then
echo "ERROR: service $service doesn't exist"
exit $STATE_CRITICAL
fi

if [ $r -ne 0 ]; then
if [[ $r -ne 0 ]]; then
echo "ERROR: service $service is $status"
exit $STATE_CRITICAL
fi


systemctl --quiet is-active $service
if [ $? -ne 0 ]; then
if [[ $? -ne 0 ]]; then
echo "ERROR: service $service is not running"
exit $STATE_CRITICAL
fi
Expand Down

0 comments on commit 8f4909c

Please sign in to comment.