check_dns.sh: redesign

check_vpn.sh: redisign
check_postfix.sh: Add support for Debian 9 (stretch).
This commit is contained in:
2017-05-17 02:07:59 +02:00
parent cdaa18f236
commit 762e6116d9
3 changed files with 362 additions and 18 deletions

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash
check_string_ps=""
if [[ -x "/usr/lib/postfix/master" ]] ; then
if [[ -x /usr/lib/postfix/sbin/master ]]; then
check_string_ps="/usr/lib/postfix/sbin/master"
elif [[ -x "/usr/lib/postfix/master" ]] ; then
check_string_ps="/usr/lib/postfix/master"
elif [[ -x "/usr/libexec/postfix/master" ]] ; then
check_string_ps="/usr/libexec/postfix/master"
@@ -108,7 +110,7 @@ if $LOGGING ; then
echo -e "\n Check if Postfix Mailservice is running.."
echo -e " ========================================="
fi
if ! ps ax | grep -e "\ ${check_string_ps}" | grep -v grep > /dev/null ; then
if ! ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}" | grep -v grep > /dev/null ; then
error "Postfix Mailservice seems to be down! Trying to restart service now.."
if $systemd_supported ; then
@@ -133,8 +135,19 @@ if ! ps ax | grep -e "\ ${check_string_ps}" | grep -v grep > /dev/null ; then
fi
fi
declare -i counter=0
PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}"| grep -v grep | awk '{print$2}')
while [[ "X${PID}" = "X" ]]; do
sleep 1
PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}"| grep -v grep | awk '{print$2}')
if [[ $counter -gt 10 ]]; then
break
else
((counter++))
fi
done
if ! ps ax | grep -e "\ ${check_string_ps}" | grep -v grep > /dev/null ; then
if [[ "X${PID}" = "X" ]] ; then
error "Restarting Postfix Mailservice failed!"
else
ok "Postfix Mailservice is up and running."