2016-08-04 12:08:16 -05:00
|
|
|
#!/bin/bash
|
2020-11-09 04:57:56 -06:00
|
|
|
set -x
|
2016-08-04 12:08:16 -05:00
|
|
|
|
2017-10-20 07:42:08 -05:00
|
|
|
target="$1"
|
2020-11-09 04:57:56 -06:00
|
|
|
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
|
|
|
|
2020-11-09 04:57:56 -06:00
|
|
|
if [ -z "$target" ]; then # || [ "$(ping -c 2 "$target" &>/dev/null; echo $?)" -ne 0 ]; then
|
2017-10-20 07:42:08 -05:00
|
|
|
echo Usage: $0 '[target]';
|
2017-02-13 20:33:58 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-02-04 02:37:50 -06:00
|
|
|
ssh $target mkdir -p /srv/yggdrasil/new_acquisition
|
2020-12-22 09:46:21 -06:00
|
|
|
timeout 60 sudo -u deluge /bin/bash -l -c 'deluge-console info' 2>/dev/null | egrep '^\[S\]' | (
|
2020-11-09 04:57:56 -06:00
|
|
|
while read line; do
|
|
|
|
id="$(echo "$line" | awk '{ print $4; }')"
|
|
|
|
name="$(echo "$line" | awk '{ print $3 }')"
|
|
|
|
# Clean up downloads before sending.
|
|
|
|
rm -Rf "$dir"/"$name"/*.nfo "$dir"/"$name"/*.txt "$dir"/"$name"/*.png "$dir"/"$name"/*.jpg
|
|
|
|
rsync -avzz "$dir"'/'"$name" $target:/srv/yggdrasil/new_acquisition
|
|
|
|
ret="$?"
|
|
|
|
if [ "$ret" -eq 0 ]; then
|
2020-12-22 09:46:21 -06:00
|
|
|
# Hack because `deluged rm -c $id` isn't working
|
|
|
|
sudo systemctl stop deluged
|
|
|
|
sudo rm -Rf /srv/deluge/.config/deluge/state"$id";
|
|
|
|
sudo systemctl start deluged
|
2020-11-09 04:57:56 -06:00
|
|
|
rm -Rf "$dir"'/'"$name"
|
|
|
|
else
|
|
|
|
echo "ERROR: Return was $ret" >> "$dir"/"$name"/error.log
|
|
|
|
fi
|
|
|
|
unset name; unset id;
|
|
|
|
done
|
2020-12-22 09:46:21 -06:00
|
|
|
) | systemd-cat -t "offload-wolfpack"
|