diff --git a/restart-postfwd.sh b/restart-postfwd.sh new file mode 100755 index 0000000..bc9a76f --- /dev/null +++ b/restart-postfwd.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +trim() { + local var="$*" + var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters + var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters + echo -n "$var" +} + +PID="$(ps -A -o pid,cmd | grep /usr/sbin/postfwd | grep -v grep | head -n 1 | awk '{print $1}')" + +if [[ -n "$(trim "$PID")" ]] ; then + kill $PID + sleep 2 +fi + +systemctl restart postfwd + +exit 0