#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TOOLNAME=$1
if [ -z $TOOLNAME ]; then
    echo "usage: gfStopTool TOOLNAME"
    exit 1;
fi

which systemctl >/dev/null 2>&1
if [ $? -eq 0 ]; then
    systemctl stop $TOOLNAME
    exit $?
fi

which service >/dev/null 2>&1
if [ $? -eq 0 ]; then
    # might need sudo askpass for this
    . $DIR/getSudoAskpass
    sudo service $TOOLNAME stop
    exit $?
fi
exit 1
