From 19055bacfd7562b39df8956592d2fb7a80e813a0 Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Wed, 17 May 2017 16:12:56 -0500 Subject: [PATCH] Migrating to Deluge from Transmission --- Makefile | 18 +++++++-- wolfpack | 87 +++++++++++++++++++++----------------------- wolfpack-stoptorrent | 2 - 3 files changed, 56 insertions(+), 51 deletions(-) delete mode 100755 wolfpack-stoptorrent diff --git a/Makefile b/Makefile index e23eebb..92f7d49 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,24 @@ +INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash + compile: ./tpb.torrentengine.sample if [ ! -d /usr/local/src/SharedLibraries ]; then git -C /usr/local/src/ clone https://aninix.net/foundation/SharedLibraries; fi git -C /usr/local/src/SharedLibraries pull; if [ ! -d /usr/local/etc/WolfPack ]; then mkdir -p /usr/local/etc/WolfPack; chmod 0770 /usr/local/etc/WolfPack; cp ./*.pup /usr/local/etc/WolfPack; cp ./tpb.torrentengine.sample /usr/local/etc/WolfPack; chmod 0660 /usr/local/etc/WolfPack/*; echo "Default configuration directory of /usr/local/etc/WolfPack created with example pups and torrent engine."; fi - @echo "Run make install and add '/usr/local/bin/wolfpack --alpha' to root's crontab to schedule data collection." + ${INSTALLER} deluge + systemctl enable deluged + systemctl start deluged -install: /usr/bin/wget /usr/bin/transmission-cli /usr/bin/googler wolfpack wolfpack-stoptorrent /usr/local/bin/whatismyip /usr/bin/lynx +install: compile /usr/bin/wget /usr/bin/deluge-console /usr/bin/googler wolfpack /usr/local/bin/whatismyip /usr/bin/lynx cp -p /usr/local/src/WolfPack/wolfpack /usr/local/bin/wolfpack - cp -p /usr/local/src/WolfPack/wolfpack-stoptorrent /usr/local/bin/wolfpack-stoptorrent make checkperm + @echo + @echo "Update the config of Deluge for privacy as needed." + @echo "https://www.privateinternetaccess.com/forum/discussion/434/utorrent-install-instructions-proxychecker" + @echo "https://www.reddit.com/r/torrents/comments/18tye4/setting_up_utorrent_with_private_internet_access/" + @echo + @echo "Add pups to /usr/local/etc/WolfPack/ to set up your searches." + @echo "Add '/usr/local/bin/wolfpack --alpha' to root's crontab to schedule data collection." + @echo WolfPack installed\! clean: @echo Nothing to do @@ -25,7 +36,6 @@ 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* diff --git a/wolfpack b/wolfpack index ce8e195..b770f9b 100755 --- a/wolfpack +++ b/wolfpack @@ -1,5 +1,7 @@ #!/bin/bash source /usr/local/src/SharedLibraries/Bash/header +export downloadtorrent="sudo -u deluge deluge-console add" + if [ -z "$3" ]; then configuretorrent /usr/local/etc/WolfPack/torrentengine else @@ -18,31 +20,36 @@ function helptext { // /~_____/ with their prey. /// \\/ / ~dev@aninix.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - wolfpack --alpha [enginefile] ~~ Tell the alpha to send the - pack members hunting. - wolfpack --member [enginefile] ~~ Send a member to train a pup - and bring back results. - wolfpack --help ~~ Show this helptext +wolfpack --alpha [enginefile] ~~ Tell the alpha to send the + pack members hunting. +wolfpack --member [enginefile] ~~ Send a member to train a + pup and bring back results. + Optionally provide a + torrent engine file. +wolfpack --torrent-monitor ~~ Pull up the Deluge console + for torrents. +wolfpack --reset-log ~~ Clear the wolfpack log. This + is in /var/log/wolfpack.log. +wolfpack --help ~~ Show this helptext - Available pup types (all pups are line-delimited with the type and - result location as the first two lines): - torrent ~~ Torrent the result of the - search term. - Will remove search line on - success. - shows ~~ Download the episode in a - show and increment. Shows - are listed in format - S01E01#Show terms - download ~~ Takes a list of commands to - run to arrive at a URL to - grab and downloads the last - URL. - search ~~ Uses the Google search - engine to return the top - five results for the search - terms on each line. - ' +Available pup types (all pups are line-delimited with the type and +result location as the first two lines): +torrent ~~ Torrent the result of the + search term. Will remove search line on + success. +shows ~~ Download the episode in a + show and increment. Shows + are listed in format + S01E01#Show terms#modifier +download ~~ Takes a list of commands to + run to arrive at a URL to + grab and downloads the last + URL. +search ~~ Uses the Google search + engine to return the top + five results for the search + terms on each line. +' } function privacycheck { @@ -61,31 +68,20 @@ function nextairdate { return } -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 - 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" - return; - fi for i in $(tail -n +3 "$1"); do getmagnetlink "$i" if [ "$magnetlink" != "" ]; then - /usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink" + /bin/bash -c "$downloadtorrent $magnetlink" sed -i "/$i/d" "$1" - echo Downloaded and removed $i | tee -a "$logfile" + echo $magnetlink | tee -a "$logfile" + echo Added magnet to deluged and removed $i | tee -a "$logfile" fi done if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi @@ -96,7 +92,6 @@ function shows { echo "Need a valid argument." return; fi - transmissioncheck; privacycheck; export downloaddir=$(head -n 2 "$1" | tail -n 1) echo "Would download to "$downloaddir @@ -116,13 +111,10 @@ function shows { if [ "$magnetlink" != "" ]; then # We found an episode. echo $i | tee -a "$logfile" - /usr/bin/transmission-cli -d 300 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink" + echo $magnetlink | tee -a "$logfile" + /bin/bash -c "$downloadtorrent $magnetlink" sed -i "s/$i/S${season}E${newep}#${showName}#${modifier}/" "$1" echo Downloaded and pup updated. | tee -a "$logfile" - rm -Rf ~/.config/transmission/resume/* - rm -Rf ~/.config/transmission/torrents/* - rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Yggdrasil - rm -f "$downloaddir"/*/*.nfo echo | tee -a "$logfile" else # We didn't -- is there a new season? @@ -133,7 +125,8 @@ function shows { fi if [ "$magnetlink" != "" ]; then 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" + echo "$magnetlink" | tee -a "$logfile" + /bin/bash -c "$downloadtorrent $magnetlink" sed -i "s/$i/S${newseason}E01#$showName#$modifier/" "$1" else nextAirDate="$(nextairdate "$showName")" @@ -239,6 +232,10 @@ case "$1" in cat /dev/null > "$logfile" exit 0; ;; + "--torrent-monitor") + exec sudo -u deluge deluge-console; + exit 0; + ;; *) helptext ;; diff --git a/wolfpack-stoptorrent b/wolfpack-stoptorrent deleted file mode 100755 index 2f3c00b..0000000 --- a/wolfpack-stoptorrent +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -killall transmission-cli