#!/usr/bin/env bash tmp_err_msg=$(mktemp) # - Is this a systemd system? # - if [[ "X`which systemd`" = "X" ]]; then systemd_exists=false else systemd_exists=true fi ## - restart clamv-daemon if process is not present ## - if ! ps -ef | grep -v grep | grep /usr/sbin/clamd > /dev/null ; then echo "clamd is down, so i try to start it.." if $systemd_exists ; then systemctl stop clamav-daemon > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi sleep 2 systemctl start clamav-daemon > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi else /etc/init.d/clamav-daemon stop > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi sleep 2 /etc/init.d/clamav-daemon start > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi fi #else # echo "clamd is up. noting to do" fi ## - restart clamv-freshclam if prozess is not present ## - if ! ps -ef | grep -v grep | grep /usr/bin/freshclam > /dev/null ; then echo "freshclam is down, so i try to start it.." if $systemd_exists ; then systemctl stop clamav-freshclam > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi sleep 2 systemctl start clamav-freshclam > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi else /etc/init.d/clamav-freshclam stop > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi sleep 2 /etc/init.d/clamav-freshclam start > /dev/null 2> $tmp_err_msg if [[ "$?" -ne 0 ]] ; then cat $tmp_err_msg fi fi #else # echo "freshclam is up. noting to do" fi rm $tmp_err_msg exit 0