From bef501886a2cf9c338135b115654eb91992264c8 Mon Sep 17 00:00:00 2001 From: cxford Date: Wed, 28 Sep 2016 14:12:16 -0500 Subject: [PATCH] Privacy fix and Makefile standardization; code reuse --- Makefile | 7 ++++--- wolfpack | 35 +++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 0111aa2..cb1bbca 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,7 @@ compile: ./1337x.torrentengine.sample install: /usr/bin/wget /usr/bin/transmission-cli /usr/bin/googler wolfpack wolfpack-stoptorrent /usr/local/bin/whatismyip cp -p /usr/local/src/WolfPack/wolfpack /usr/local/bin/wolfpack cp -p /usr/local/src/WolfPack/wolfpack-stoptorrent /usr/local/bin/wolfpack-stoptorrent - chmod 0700 /usr/local/bin/wolfpack-stoptorrent - chmod 0755 /usr/local/bin/wolfpack - chown root:root /usr/local/bin/wolfpack* + make checkperm clean: @echo Nothing to do @@ -26,6 +24,9 @@ reverse: checkperm: /usr/local/etc/WolfPack/ chmod -R ug+rw /usr/local/etc/WolfPack/ chmod 0770 /usr/local/etc/WolfPack/ + chmod 0700 /usr/local/bin/wolfpack-stoptorrent + chmod 0755 /usr/local/bin/wolfpack + chown root:root /usr/local/bin/wolfpack* offload: offload-wolfpack /root/.ssh/id_rsa /root/.ssh/id_rsa.pub cp offload-wolfpack /root/bin diff --git a/wolfpack b/wolfpack index 7d6af3d..6336452 100755 --- a/wolfpack +++ b/wolfpack @@ -43,15 +43,28 @@ search ~~ Uses the Google search ' } +function privacycheck { + if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ' | tail -n 1)" ]; then + echo "Should not torrent directly from the AniNIX main IP for privacy reasons" 2>&1 | tee -a $logfile + exit 1 + fi +} + +function transmissioncheck { + if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then + echo "Transmission is still running. Aborting." | tee -a $logfile + exit 0; + fi +} + + function torrent { if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then echo "Need a valid argument." return; fi - if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ')" ]; then - echo "Should not torrent directly from the AniNIX main IP for privacy reasons" 1>&2 - exit 1 - fi + transmissioncheck; + privacycheck; export downloaddir=$(head -n 2 "$1" | tail -n 1) if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then echo "Transmission is still running. Aborting." | tee -a $logfile @@ -82,21 +95,15 @@ function shows { echo "Need a valid argument." return; fi - if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then - echo "Transmission is still running. Aborting." | tee -a $logfile - return; - fi - if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ')" ]; then - echo "Should not torrent directly from the AniNIX main IP for privacy reasons" 1>&2 - exit 1 - fi + transmissioncheck; + privacycheck; export downloaddir=$(head -n 2 "$1" | tail -n 1) echo "Would download to "$downloaddir for i in $(tail -n +3 "$1"); do export searchsegment="$(echo $i | tr '#' '+' | tr ' ' '+')" export searchlink="$(printf "$torrentengine" "$searchsegment")" export searchresult=$(wget -q -O - "$searchlink" | bash -c "$torrentterms") - export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d \") + export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d $magnetseparator) if [ $torrentdebugging == "true" ]; then echo $searchstring echo $searchlink @@ -129,7 +136,7 @@ function shows { export newseason=$(printf "%02d\n" $((${season#0} + 1))) export newsearch="$(echo $searchlink | sed 's/S'$season'E'$episode'/S'$newseason'E01/')" export searchresult=$(wget -q -O - "$newsearch" | bash -c "$torrentterms") - export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d \") + export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d $magnetseparator) if [ $torrentdebugging == "true" ]; then echo $newseason echo $newsearch