Add script 'restart-postfwd.sh'.

This commit is contained in:
Christoph 2023-12-09 00:14:15 +01:00
parent 033c95c9ce
commit a80402529f

19
restart-postfwd.sh Executable file
View File

@ -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