ClamCron/ClamCron.sh

93 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# ======================================================================================
# Script for Scanning Directories with ClamScan at Regular Intervals
# ======================================================================================
#
: '
Title :
ClamCron.sh
Directories ALWAYS ignored :
--proc
--sys
--dev
--quarantine
Action taken for positive results:
Moved to a quarantine folder defined in conf file.
Usage :
Set settings in ClamCron.conf file.
Run this script at the frequency you wish with a cronjob.
';
#################### LOAD CONF ####################
CONF_FILE="$( cd "$( dirname "${BASH_SOURCE[0]}" )/conf/" && readlink -f "ClamCron.conf" )";
##################### SANITY #####################
if [ ! -f "$CONF_FILE" ]; then
echo "Required CONF_FILE.conf was not loaded, please verify it is present and loadable.";
exit 1;
fi
source "$CONF_FILE";
###################### MAIN ######################
function main() {
start_log;
echo "" > "$SCRIPT_TMP";
echo_log "$LOG_KICKOFF $SCAN_DIR"
nohup $CLAMSCAN_LOC -roi "$SCAN_DIR" \
--exclude-dir="^/proc" \
--exclude-dir="^/sys" \
--exclude="/dev" \
--exclude-dir="quarantine/" \
--move="$QUAR_DIR" \
-l "$SCRIPT_TMP" &>/dev/null;
cat "$SCRIPT_TMP" | tee -a "$SCRIPT_LOG";
end_log;
}
###################### SUBS ######################
function start_log() {
echo -e "$LOG_BEGIN" | tee -a "$SCRIPT_LOG";
}
function end_log() {
echo -e "$LOG_END" | tee -a "$SCRIPT_LOG";
}
function echo_log() {
echo -e "\n$1\n" | tee -a "$SCRIPT_LOG";
}
##################### INIT ######################
main;
exit 1;