From b73e1c3610966e818536c87e8f86c71e0687d919 Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Thu, 2 Feb 2017 14:36:30 -0600 Subject: [PATCH] Fixes for download bug; virus scanning by default if VirusScan is installed --- wolfpack | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wolfpack b/wolfpack index 9387602..ce8e195 100755 --- a/wolfpack +++ b/wolfpack @@ -88,6 +88,7 @@ function torrent { echo Downloaded and removed $i | tee -a "$logfile" fi done + if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi } function shows { @@ -147,6 +148,7 @@ function shows { fi fi done + if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi } function download { @@ -158,24 +160,23 @@ function download { export downloaddir=$(head -n 2 "$1" | tail -n 1) # The third line and any following lines should be for i in $(tail -n +3 "$1"); do - #echo EVALUATING: $i - if [ "$i" == "" ]; then continue; fi + if [ -z "$i" ]; then continue; fi export comm=$(echo $i | sed "s#PREVRESULT#$nexturl#g" -) export nexturl=$(bash -c "$comm") - #echo Found next url: $nexturl done export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)" #if file doesn't already exist.... if [ ! -f "$filename" ]; then echo Downloading $nexturl to $filename ... | tee -a "$logfile" - export dedupterm="$(echo $1 | cut -f 1 -d '.' | rev | cut -f 1 -d '/' | rev)" - for i in $(find "$downloaddir" | grep -i "$dedupterm"); do + export dedupterm="$(echo $1 | rev | cut -f 1 -d '/' | rev | cut -f 1 -d '.')" + for i in $(find -type f "$downloaddir" | grep -i "$dedupterm"); do echo Deduped! Removed $i from $downloaddir | tee -a "$logfile" - rm -Rf $i; + rm -f "$downloaddir"/"$i" 2>&1 | tee -a "$logfile" done wget --timeout=5 -q -O "$filename" "$nexturl" echo Downloaded | tee -a "$logfile" fi + if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi } function search { @@ -198,10 +199,10 @@ if [ "$1" == "" ]; then fi echo '---' $(date) '---' | tee -a "$logfile" -echo Started "$1" "$2" on $(uname -n) | tee -a "$logfile" case "$1" in "--alpha") + echo Started alpha on `uname -n` | tee -a "$logfile" if [ "$2" == "" ]; then export basedir="/usr/local/etc/WolfPack" else @@ -214,8 +215,8 @@ case "$1" in ;; "--member") - echo "Spawning a member for "$2 | tee -a "$logfile" - whatismyip | tee -a /var/log/wolfpack.log + echo "Spawning a $(head -n 1 "$2") member for $2 on `uname -n`" | tee -a "$logfile" + (printf "IP: "; whatismyip) | tee -a /var/log/wolfpack.log case "$(head -n 1 "$2")" in "shows") shows "$2"