2016-08-04 12:08:16 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-01-18 20:27:33 -06:00
|
|
|
logfile=/var/log/wolfpack.log
|
2017-10-20 07:42:08 -05:00
|
|
|
target="$1"
|
|
|
|
dir=`sudo -u deluge deluge-console config download_location 2>/dev/null | head -n 1 | sed 's/ download_location: //'`
|
2017-01-18 20:27:33 -06:00
|
|
|
|
2017-10-20 07:42:08 -05:00
|
|
|
if [ -z "$target" ]; then
|
|
|
|
echo Usage: $0 '[target]';
|
2017-02-13 20:33:58 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-10-20 07:42:08 -05:00
|
|
|
|
|
|
|
sudo -u deluge deluge-console info 2>/dev/null | (
|
|
|
|
unset name;
|
|
|
|
unset id;
|
|
|
|
unset state;
|
|
|
|
while read line; do
|
|
|
|
case "$line" in
|
|
|
|
"Name:"*) name="$(echo $line | sed 's/Name: //')"; ;;
|
|
|
|
"State:"*) state="$(echo $line | cut -f 2 -d ' ')"; ;;
|
|
|
|
"ID:"*) id="$(echo $line | sed 's/ID: //')"; ;;
|
|
|
|
*)
|
|
|
|
if [ ! -z "$name" ] && [ ! -z "$id" ] && [ ! -z "$state" ]; then
|
|
|
|
echo Found "$name" "($id)" with state "$state"
|
|
|
|
if [ -e "$dir"'/'"$name" ]; then
|
|
|
|
echo "$name" exists on disk.
|
|
|
|
fi
|
|
|
|
if [ "$state" == "Seeding" ]; then
|
|
|
|
sudo -u deluge deluge-console 2>/dev/null rm "$id";
|
|
|
|
rsync -avz "$dir"'/'"$name" $target:/srv/yggdrasil/new_acquisition
|
|
|
|
ret="$?"
|
|
|
|
if [ "$ret" -eq 0 ]; then
|
|
|
|
rm -Rf "$dir"'/'"$name"
|
|
|
|
else
|
|
|
|
echo "ERROR: Return was $ret" >> "$dir"/"$name"/error.log
|
|
|
|
fi
|
|
|
|
fi;
|
|
|
|
unset name; unset id; unset state;
|
|
|
|
fi ;;
|
|
|
|
esac
|
|
|
|
done)
|
|
|
|
cat /var/log/wolfpack.log | ssh $target /bin/bash -c 'cat >> /var/log/wolfpack.log'
|
|
|
|
cat /dev/null > /var/log/wolfpack.log
|