Base Code
parent
fec7eca33d
commit
7deaed1693
|
|
@ -0,0 +1,31 @@
|
|||
# Git Ignore
|
||||
######################
|
||||
|
||||
# For this script
|
||||
######################
|
||||
quarantine/
|
||||
log/
|
||||
ClamCron.conf
|
||||
|
||||
# Track this file
|
||||
######################
|
||||
!.gitignore
|
||||
|
||||
# Project #
|
||||
######################
|
||||
.local-only/
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
.Spotlight-V100
|
||||
.Trashes*
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
.fuse*
|
||||
|
||||
# CUSTOM #
|
||||
######################
|
||||
log/*
|
||||
!log/.gitignore
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
#!/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;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
export SCAN_DIR="/";
|
||||
|
||||
export CLAMSCAN_LOC="/usr/bin/clamscan";
|
||||
|
||||
export SCRIPT_NAME="ClamCron";
|
||||
|
||||
export DATE_CUR=$(date '+%Y-%m-%d__%H:%M:%S');
|
||||
|
||||
export SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )";
|
||||
|
||||
export SCRIPT_TMP="$SCRIPT_DIR/log/$SCRIPT_NAME.tmp";
|
||||
|
||||
export SCRIPT_LOG="$SCRIPT_DIR/log/$SCRIPT_NAME--$DATE_CUR.log";
|
||||
|
||||
export QUAR_DIR="$SCRIPT_DIR/quarantine";
|
||||
|
||||
export LOG_BEGIN="=================================================================
|
||||
|| ||
|
||||
|| SuperDuper $SCRIPT_NAME ||
|
||||
|| $DATE_CUR ||
|
||||
|| ||
|
||||
=================================================================
|
||||
";
|
||||
|
||||
export LOG_KICKOFF="----------- SCAN KICKOFF -----------\nScanning Directory:";
|
||||
|
||||
export LOG_END="
|
||||
|
||||
=================================================================
|
||||
||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~||
|
||||
=================================================================";
|
||||
Loading…
Reference in New Issue