Privacy fix and Makefile standardization; code reuse

This commit is contained in:
cxford 2016-09-28 14:12:16 -05:00
parent 10335ae2df
commit bef501886a
2 changed files with 25 additions and 17 deletions

View File

@ -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 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 /usr/local/bin/wolfpack
cp -p /usr/local/src/WolfPack/wolfpack-stoptorrent /usr/local/bin/wolfpack-stoptorrent cp -p /usr/local/src/WolfPack/wolfpack-stoptorrent /usr/local/bin/wolfpack-stoptorrent
chmod 0700 /usr/local/bin/wolfpack-stoptorrent make checkperm
chmod 0755 /usr/local/bin/wolfpack
chown root:root /usr/local/bin/wolfpack*
clean: clean:
@echo Nothing to do @echo Nothing to do
@ -26,6 +24,9 @@ reverse:
checkperm: /usr/local/etc/WolfPack/ checkperm: /usr/local/etc/WolfPack/
chmod -R ug+rw /usr/local/etc/WolfPack/ chmod -R ug+rw /usr/local/etc/WolfPack/
chmod 0770 /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 offload: offload-wolfpack /root/.ssh/id_rsa /root/.ssh/id_rsa.pub
cp offload-wolfpack /root/bin cp offload-wolfpack /root/bin

View File

@ -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 { function torrent {
if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then
echo "Need a valid argument." echo "Need a valid argument."
return; return;
fi fi
if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ')" ]; then transmissioncheck;
echo "Should not torrent directly from the AniNIX main IP for privacy reasons" 1>&2 privacycheck;
exit 1
fi
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
@ -82,21 +95,15 @@ function shows {
echo "Need a valid argument." echo "Need a valid argument."
return; return;
fi fi
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then transmissioncheck;
echo "Transmission is still running. Aborting." | tee -a $logfile privacycheck;
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
export downloaddir=$(head -n 2 "$1" | tail -n 1) export downloaddir=$(head -n 2 "$1" | tail -n 1)
echo "Would download to "$downloaddir echo "Would download to "$downloaddir
for i in $(tail -n +3 "$1"); do for i in $(tail -n +3 "$1"); do
export searchsegment="$(echo $i | tr '#' '+' | tr ' ' '+')" export searchsegment="$(echo $i | tr '#' '+' | tr ' ' '+')"
export searchlink="$(printf "$torrentengine" "$searchsegment")" export searchlink="$(printf "$torrentengine" "$searchsegment")"
export searchresult=$(wget -q -O - "$searchlink" | bash -c "$torrentterms") 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 if [ $torrentdebugging == "true" ]; then
echo $searchstring echo $searchstring
echo $searchlink echo $searchlink
@ -129,7 +136,7 @@ function shows {
export newseason=$(printf "%02d\n" $((${season#0} + 1))) export newseason=$(printf "%02d\n" $((${season#0} + 1)))
export newsearch="$(echo $searchlink | sed 's/S'$season'E'$episode'/S'$newseason'E01/')" export newsearch="$(echo $searchlink | sed 's/S'$season'E'$episode'/S'$newseason'E01/')"
export searchresult=$(wget -q -O - "$newsearch" | bash -c "$torrentterms") 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 if [ $torrentdebugging == "true" ]; then
echo $newseason echo $newseason
echo $newsearch echo $newsearch