Migrating to Deluge from Transmission

This commit is contained in:
DarkFeather 2017-05-17 16:12:56 -05:00
parent 62e0619988
commit 19055bacfd
3 changed files with 56 additions and 51 deletions

View File

@ -1,13 +1,24 @@
INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash
compile: ./tpb.torrentengine.sample compile: ./tpb.torrentengine.sample
if [ ! -d /usr/local/src/SharedLibraries ]; then git -C /usr/local/src/ clone https://aninix.net/foundation/SharedLibraries; fi 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; 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 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 /usr/local/bin/wolfpack
cp -p /usr/local/src/WolfPack/wolfpack-stoptorrent /usr/local/bin/wolfpack-stoptorrent
make checkperm 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: clean:
@echo Nothing to do @echo Nothing to do
@ -25,7 +36,6 @@ 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 chmod 0755 /usr/local/bin/wolfpack
chown root:root /usr/local/bin/wolfpack* chown root:root /usr/local/bin/wolfpack*

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
source /usr/local/src/SharedLibraries/Bash/header source /usr/local/src/SharedLibraries/Bash/header
export downloadtorrent="sudo -u deluge deluge-console add"
if [ -z "$3" ]; then if [ -z "$3" ]; then
configuretorrent /usr/local/etc/WolfPack/torrentengine configuretorrent /usr/local/etc/WolfPack/torrentengine
else else
@ -18,31 +20,36 @@ function helptext {
// /~_____/ with their prey. // /~_____/ with their prey.
/// \\/ / ~dev@aninix.net /// \\/ / ~dev@aninix.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wolfpack --alpha [enginefile] ~~ Tell the alpha to send the wolfpack --alpha [enginefile] ~~ Tell the alpha to send the
pack members hunting. pack members hunting.
wolfpack --member <pup> [enginefile] ~~ Send a member to train a pup wolfpack --member <pup> [enginefile] ~~ Send a member to train a
and bring back results. pup and bring back results.
wolfpack --help ~~ Show this helptext 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 Available pup types (all pups are line-delimited with the type and
result location as the first two lines): result location as the first two lines):
torrent ~~ Torrent the result of the torrent ~~ Torrent the result of the
search term. search term. Will remove search line on
Will remove search line on success.
success. shows ~~ Download the episode in a
shows ~~ Download the episode in a show and increment. Shows
show and increment. Shows are listed in format
are listed in format S01E01#Show terms#modifier
S01E01#Show terms download ~~ Takes a list of commands to
download ~~ Takes a list of commands to run to arrive at a URL to
run to arrive at a URL to grab and downloads the last
grab and downloads the last URL.
URL. search ~~ Uses the Google search
search ~~ Uses the Google search engine to return the top
engine to return the top five results for the search
five results for the search terms on each line.
terms on each line. '
'
} }
function privacycheck { function privacycheck {
@ -61,31 +68,20 @@ function nextairdate {
return 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 { 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
transmissioncheck;
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
echo "Transmission is still running. Aborting." | tee -a "$logfile"
return;
fi
for i in $(tail -n +3 "$1"); do for i in $(tail -n +3 "$1"); do
getmagnetlink "$i" getmagnetlink "$i"
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" /bin/bash -c "$downloadtorrent $magnetlink"
sed -i "/$i/d" "$1" 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 fi
done done
if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi if [ -x `which clamscan` ]; then clamscan -r -i "$downloaddir" | tee -a "$logfile"; fi
@ -96,7 +92,6 @@ function shows {
echo "Need a valid argument." echo "Need a valid argument."
return; return;
fi fi
transmissioncheck;
privacycheck; privacycheck;
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
@ -116,13 +111,10 @@ function shows {
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" echo $magnetlink | tee -a "$logfile"
/bin/bash -c "$downloadtorrent $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/torrents/*
rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Yggdrasil
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?
@ -133,7 +125,8 @@ function shows {
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" echo "$magnetlink" | tee -a "$logfile"
/bin/bash -c "$downloadtorrent $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")"
@ -239,6 +232,10 @@ case "$1" in
cat /dev/null > "$logfile" cat /dev/null > "$logfile"
exit 0; exit 0;
;; ;;
"--torrent-monitor")
exec sudo -u deluge deluge-console;
exit 0;
;;
*) *)
helptext helptext
;; ;;

View File

@ -1,2 +0,0 @@
#!/bin/bash
killall transmission-cli