Fixes for download bug; virus scanning by default if VirusScan is installed

This commit is contained in:
DarkFeather 2017-02-02 14:36:30 -06:00
parent 8eff907b0d
commit b73e1c3610

View File

@ -88,6 +88,7 @@ function torrent {
echo Downloaded and removed $i | tee -a "$logfile" echo Downloaded and removed $i | tee -a "$logfile"
fi fi
done done
if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi
} }
function shows { function shows {
@ -147,6 +148,7 @@ function shows {
fi fi
fi fi
done done
if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi
} }
function download { function download {
@ -158,24 +160,23 @@ function download {
export downloaddir=$(head -n 2 "$1" | tail -n 1) export downloaddir=$(head -n 2 "$1" | tail -n 1)
# The third line and any following lines should be # The third line and any following lines should be
for i in $(tail -n +3 "$1"); do for i in $(tail -n +3 "$1"); do
#echo EVALUATING: $i if [ -z "$i" ]; then continue; fi
if [ "$i" == "" ]; then continue; fi
export comm=$(echo $i | sed "s#PREVRESULT#$nexturl#g" -) export comm=$(echo $i | sed "s#PREVRESULT#$nexturl#g" -)
export nexturl=$(bash -c "$comm") export nexturl=$(bash -c "$comm")
#echo Found next url: $nexturl
done done
export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)" export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)"
#if file doesn't already exist.... #if file doesn't already exist....
if [ ! -f "$filename" ]; then if [ ! -f "$filename" ]; then
echo Downloading $nexturl to $filename ... | tee -a "$logfile" echo Downloading $nexturl to $filename ... | tee -a "$logfile"
export dedupterm="$(echo $1 | cut -f 1 -d '.' | rev | cut -f 1 -d '/' | rev)" export dedupterm="$(echo $1 | rev | cut -f 1 -d '/' | rev | cut -f 1 -d '.')"
for i in $(find "$downloaddir" | grep -i "$dedupterm"); do for i in $(find -type f "$downloaddir" | grep -i "$dedupterm"); do
echo Deduped! Removed $i from $downloaddir | tee -a "$logfile" echo Deduped! Removed $i from $downloaddir | tee -a "$logfile"
rm -Rf $i; rm -f "$downloaddir"/"$i" 2>&1 | tee -a "$logfile"
done done
wget --timeout=5 -q -O "$filename" "$nexturl" wget --timeout=5 -q -O "$filename" "$nexturl"
echo Downloaded | tee -a "$logfile" echo Downloaded | tee -a "$logfile"
fi fi
if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi
} }
function search { function search {
@ -198,10 +199,10 @@ if [ "$1" == "" ]; then
fi fi
echo '---' $(date) '---' | tee -a "$logfile" echo '---' $(date) '---' | tee -a "$logfile"
echo Started "$1" "$2" on $(uname -n) | tee -a "$logfile"
case "$1" in case "$1" in
"--alpha") "--alpha")
echo Started alpha on `uname -n` | tee -a "$logfile"
if [ "$2" == "" ]; then if [ "$2" == "" ]; then
export basedir="/usr/local/etc/WolfPack" export basedir="/usr/local/etc/WolfPack"
else else
@ -214,8 +215,8 @@ case "$1" in
;; ;;
"--member") "--member")
echo "Spawning a member for "$2 | tee -a "$logfile" echo "Spawning a $(head -n 1 "$2") member for $2 on `uname -n`" | tee -a "$logfile"
whatismyip | tee -a /var/log/wolfpack.log (printf "IP: "; whatismyip) | tee -a /var/log/wolfpack.log
case "$(head -n 1 "$2")" in case "$(head -n 1 "$2")" in
"shows") "shows")
shows "$2" shows "$2"