Add configuration directory, move configuration files to new directory

This commit is contained in:
Christoph 2017-02-12 23:56:39 +01:00
parent 903d594079
commit 1e5a776839
2 changed files with 74 additions and 0 deletions

74
check_clamav-daemon.sh Executable file
View File

@ -0,0 +1,74 @@
#!/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