Updates for deluge output reformat

This commit is contained in:
DarkFeather 2020-11-09 04:57:56 -06:00
parent 742a58d2c2
commit dfa79db9c7
Signed by: DarkFeather
GPG Key ID: 1CC1E3F4ED06F296

View File

@ -1,42 +1,31 @@
#!/bin/bash #!/bin/bash
set -x
logfile=/var/log/wolfpack.log logfile=/var/log/wolfpack.log
target="$1" target="$1"
dir=`sudo -u deluge deluge-console config download_location 2>/dev/null | head -n 1 | sed 's/ download_location: //'` dir=`sudo -u deluge deluge-console config download_location 2>/dev/null | head -n 1 | sed 's/download_location: //'`
if [ -z "$target" ] || [ "$(ping -c 2 "$target" &>/dev/null; echo $?)" -ne 0 ]; then if [ -z "$target" ]; then # || [ "$(ping -c 2 "$target" &>/dev/null; echo $?)" -ne 0 ]; then
echo Usage: $0 '[target]'; echo Usage: $0 '[target]';
exit 1 exit 1
fi fi
ssh $target mkdir -p /srv/yggdrasil/new_acquisition ssh $target mkdir -p /srv/yggdrasil/new_acquisition
sudo -u deluge deluge-console info 2>/dev/null | ( sudo -u deluge deluge-console info 2>/dev/null | egrep '^\[S\]' | (
unset name; while read line; do
unset id; id="$(echo "$line" | awk '{ print $4; }')"
unset state; name="$(echo "$line" | awk '{ print $3 }')"
while read line; do sudo -u deluge deluge-console 2>/dev/null rm "$id";
case "$line" in # Clean up downloads before sending.
"Name:"*) name="$(echo $line | sed 's/Name: //')"; ;; rm -Rf "$dir"/"$name"/*.nfo "$dir"/"$name"/*.txt "$dir"/"$name"/*.png "$dir"/"$name"/*.jpg
"State:"*) state="$(echo $line | cut -f 2 -d ' ')"; ;; rsync -avzz "$dir"'/'"$name" $target:/srv/yggdrasil/new_acquisition
"ID:"*) id="$(echo $line | sed 's/ID: //')"; ;; ret="$?"
*) if [ "$ret" -eq 0 ]; then
if [ ! -z "$name" ] && [ ! -z "$id" ] && [ ! -z "$state" ]; then rm -Rf "$dir"'/'"$name"
echo Found "$name" "($id)" with state "$state" else
if [ -e "$dir"'/'"$name" ]; then echo "ERROR: Return was $ret" >> "$dir"/"$name"/error.log
echo "$name" exists on disk. fi
fi unset name; unset id;
if [ "$state" == "Seeding" ]; then done
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 /var/log/wolfpack.log | ssh $target /bin/bash -c 'cat >> /var/log/wolfpack.log'
cat /dev/null > /var/log/wolfpack.log cat /dev/null > /var/log/wolfpack.log