check_postfix.sh: fix error if distribution is not Debian or Ubuntu.

This commit is contained in:
Christoph 2018-12-27 19:36:16 +01:00
parent 3036be6061
commit bb7ca4089b

View File

@ -181,29 +181,27 @@ if ! ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}" | grep -v grep > /dev/n
# - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg) # - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg)
# - # -
if [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ; then if ( [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ) \
if $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then && $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then
warn "It seems that package management (apt,dpkg) is running. Exiting restarting the service .." warn "It seems that package management (apt,dpkg) is running. Exiting restarting the service .."
else
$systemctl stop postfix > /dev/null 2> ${LOCK_DIR}/err_msg.log
if [[ $? -ne 0 ]]; then
error "$(cat ${LOCK_DIR}/err_msg.log)"
fi
sleep 10
# - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg)
# -
if ( [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ) \
&& $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then
warn "It seems that package management (apt,dpkg) is running. Omit starting the service .."
else else
$systemctl stop postfix > /dev/null 2> ${LOCK_DIR}/err_msg.log $systemctl start postfix > /dev/null 2> ${LOCK_DIR}/err_msg.log
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
error "$(cat ${LOCK_DIR}/err_msg.log)" error "$(cat ${LOCK_DIR}/err_msg.log)"
fi fi
sleep 10
# - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg)
# -
if [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ; then
if $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then
warn "It seems that package management (apt,dpkg) is running. Omit starting the service .."
else
$systemctl start postfix > /dev/null 2> ${LOCK_DIR}/err_msg.log
if [[ $? -ne 0 ]]; then
error "$(cat ${LOCK_DIR}/err_msg.log)"
fi
fi
fi
fi fi
fi fi
@ -211,31 +209,29 @@ if ! ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}" | grep -v grep > /dev/n
# - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg) # - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg)
# - # -
if [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ; then if ( [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ) \
if $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then && $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then
warn "It seems that package management (apt,dpkg) is running - Exiting restarting the service .." warn "It seems that package management (apt,dpkg) is running - Exiting restarting the service .."
else else
$postfix_init_script stop > /dev/null 2>&1 $postfix_init_script stop > /dev/null 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
error "Stopping Postfix Mailservice failed!" error "Stopping Postfix Mailservice failed!"
fi
sleep 10
# - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg)
# -
if [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ; then
if $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then
warn "It seems that package management (apt,dpkg) is running. Omit starting the service .."
else
$postfix_init_script start > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
error "Starting Postfix Mailservice failed!"
fi
fi
fi
fi fi
sleep 10
# - Don't Start/Stop Services if package management is running (apt,aptitude,dpkg)
# -
if ( [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ) \
&& $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then
warn "It seems that package management (apt,dpkg) is running. Omit starting the service .."
else
$postfix_init_script start > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
error "Starting Postfix Mailservice failed!"
fi
fi
fi fi
fi fi