postfix/restart-postfwd.sh

20 lines
436 B
Bash
Executable File

#!/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