check_process.sh: fix bsd

This commit is contained in:
Cyberes 2023-06-08 12:30:44 -06:00
parent f4732d2fd5
commit 5a34281bde
Signed by: cyberes
GPG Key ID: 6B4A33836A9500FE
1 changed files with 6 additions and 2 deletions

View File

@ -38,8 +38,12 @@ if [ -z "$pretty_service_name" ]; then
pretty_service_name="$process_name"
fi
# Check if the process is running
process_count=$(pgrep -f "$process_name" 2>/dev/null | wc -l)
if uname | grep -q "BSD"; then
# have to run pgrep with sudo in BSD
process_count=$(sudo pgrep -f "$process_name" 2>/dev/null | wc -l)
else
process_count=$(pgrep -f "$process_name" 2>/dev/null | wc -l)
fi
if [ $? -ne 0 ]; then
echo "UNKNOWN - Check failed"