Reset log function, quotes

This commit is contained in:
DarkFeather 2017-01-24 10:10:25 -06:00
parent 360f91458a
commit 8eff907b0d
1 changed files with 26 additions and 23 deletions

View File

@ -47,7 +47,7 @@ function helptext {
function privacycheck { function privacycheck {
if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ' | tail -n 1)" ]; then if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ' | tail -n 1)" ]; then
echo "ERROR: Should not torrent directly from the AniNIX main IP for privacy reasons" 2>&1 | tee -a $logfile echo "ERROR: Should not torrent directly from the AniNIX main IP for privacy reasons" 2>&1 | tee -a "$logfile"
exit 1 exit 1
fi fi
} }
@ -63,7 +63,7 @@ function nextairdate {
function transmissioncheck { function transmissioncheck {
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
echo "Transmission is still running. Aborting." | tee -a $logfile echo "Transmission is still running. Aborting." | tee -a "$logfile"
exit 0; exit 0;
fi fi
} }
@ -77,7 +77,7 @@ function torrent {
privacycheck; privacycheck;
export downloaddir=$(head -n 2 "$1" | tail -n 1) export downloaddir=$(head -n 2 "$1" | tail -n 1)
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
echo "Transmission is still running. Aborting." | tee -a $logfile echo "Transmission is still running. Aborting." | tee -a "$logfile"
return; return;
fi fi
for i in $(tail -n +3 "$1"); do for i in $(tail -n +3 "$1"); do
@ -85,7 +85,7 @@ function torrent {
if [ "$magnetlink" != "" ]; then if [ "$magnetlink" != "" ]; then
/usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink" /usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
sed -i "/$i/d" "$1" sed -i "/$i/d" "$1"
echo Downloaded and removed $i | tee -a $logfile echo Downloaded and removed $i | tee -a "$logfile"
fi fi
done done
} }
@ -114,15 +114,15 @@ function shows {
fi fi
if [ "$magnetlink" != "" ]; then if [ "$magnetlink" != "" ]; then
# We found an episode. # We found an episode.
echo $i | tee -a $logfile echo $i | tee -a "$logfile"
/usr/bin/transmission-cli -d 300 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink" /usr/bin/transmission-cli -d 300 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
sed -i "s/$i/S${season}E${newep}#${showName}#${modifier}/" "$1" sed -i "s/$i/S${season}E${newep}#${showName}#${modifier}/" "$1"
echo Downloaded and pup updated. | tee -a $logfile echo Downloaded and pup updated. | tee -a "$logfile"
rm -Rf ~/.config/transmission/resume/* rm -Rf ~/.config/transmission/resume/*
rm -Rf ~/.config/transmission/torrents/* rm -Rf ~/.config/transmission/torrents/*
rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Yggdrasil rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Yggdrasil
rm -f "$downloaddir"/*/*.nfo rm -f "$downloaddir"/*/*.nfo
echo | tee -a $logfile echo | tee -a "$logfile"
else else
# We didn't -- is there a new season? # We didn't -- is there a new season?
if [ -z "$modifier" ]; then if [ -z "$modifier" ]; then
@ -131,18 +131,18 @@ function shows {
getmagnetlink "$showName S${newseason}E01 $modifier" getmagnetlink "$showName S${newseason}E01 $modifier"
fi fi
if [ "$magnetlink" != "" ]; then if [ "$magnetlink" != "" ]; then
echo "S${newseason}E01" $showName | tee -a $logfile echo "S${newseason}E01" $showName | tee -a "$logfile"
/usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink" /usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
sed -i "s/$i/S${newseason}E01#$showName#$modifier/" "$1" sed -i "s/$i/S${newseason}E01#$showName#$modifier/" "$1"
else else
nextAirDate="$(nextairdate "$showName")" nextAirDate="$(nextairdate "$showName")"
if [ ! -z "$nextAirDate" ]; then if [ ! -z "$nextAirDate" ]; then
echo "No new season found for $showName -- next airs $(nextairdate "$showName")" | tee -a $logfile echo "No new season found for $showName -- next airs $(nextairdate "$showName")" | tee -a "$logfile"
if [ "$(date -s "$nextAirDate" -u +%s)" -lt "$(date -u +%s)" ]; then if [ "$(date -s "$nextAirDate" -u +%s)" -lt "$(date -u +%s)" ]; then
echo ERROR: Should have found a new episode for $searchterms and did not -- check your provider\! | tee -a $logfile echo ERROR: Should have found a new episode for $searchterms and did not -- check your provider\! | tee -a "$logfile"
fi fi
else else
echo "No new season found for $showName" | tee -a $logfile echo "No new season found for $showName" | tee -a "$logfile"
fi fi
fi fi
fi fi
@ -167,14 +167,14 @@ function download {
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 | cut -f 1 -d '.' | rev | cut -f 1 -d '/' | rev)"
for i in $(find "$downloaddir" | grep -i "$dedupterm"); do for i in $(find "$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 -Rf $i;
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
} }
@ -188,7 +188,7 @@ function search {
export searchstring=$(echo $i | sed 's/ /+/g') export searchstring=$(echo $i | sed 's/ /+/g')
export file="$downloaddir"/$searchstring'.txt' export file="$downloaddir"/$searchstring'.txt'
echo | googler --count=5 -C -x "$searchstring" | grep -v 'Enter n, p, result' > "$file" echo | googler --count=5 -C -x "$searchstring" | grep -v 'Enter n, p, result' > "$file"
echo "Ran search for $searchstring to $file" | tee -a $logfile echo "Ran search for $searchstring to $file" | tee -a "$logfile"
done done
} }
@ -197,8 +197,8 @@ if [ "$1" == "" ]; then
exit 1; exit 1;
fi fi
echo '---' $(date) '---' | tee -a $logfile echo '---' $(date) '---' | tee -a "$logfile"
echo Started "$1" "$2" on $(uname -n) | tee -a $logfile echo Started "$1" "$2" on $(uname -n) | tee -a "$logfile"
case "$1" in case "$1" in
"--alpha") "--alpha")
@ -207,14 +207,14 @@ case "$1" in
else else
export basedir="$2"; export basedir="$2";
fi fi
echo "Starting members from pup in "$basedir | tee -a $logfile echo "Starting members from pup in "$basedir | tee -a "$logfile"
for i in $(find "$basedir" -type f | grep '.pup'); do for i in $(find "$basedir" -type f | grep '.pup'); do
/usr/local/bin/wolfpack --member "$i" "$3"; /usr/local/bin/wolfpack --member "$i" "$3";
done done
;; ;;
"--member") "--member")
echo "Spawning a member for "$2 | tee -a $logfile echo "Spawning a member for "$2 | tee -a "$logfile"
whatismyip | tee -a /var/log/wolfpack.log whatismyip | tee -a /var/log/wolfpack.log
case "$(head -n 1 "$2")" in case "$(head -n 1 "$2")" in
"shows") "shows")
@ -234,12 +234,15 @@ case "$1" in
;; ;;
esac esac
;; ;;
"--reset-log")
cat /dev/null > "$logfile"
exit 0;
;;
*) *)
helptext helptext
;; ;;
esac esac
echo "Exited "$1 | tee -a $logfile echo "Exited "$1 | tee -a "$logfile"
echo '---' "$(date)" '---' | tee -a $logfile echo '---' "$(date)" '---' | tee -a "$logfile"
echo | tee -a $logfile echo | tee -a "$logfile"