#!/bin/bash status=0 ip1="10.120.152.1" ip2="192.168.0.250" ip r | grep 10.120.152.1 if [[ $? == 0 ]]; then ping -c 1 10.120.152.1 if [[ $? == 0 ]]; then ip=$ip1 fi else ping -c 1 192.168.0.250 if [[ $? == 0 ]]; then ip=$ip2 fi fi if [[ -n "$ip" ]]; then echo "Sending" rsync -avP --delete-after --progress -e "ssh" "./sf/" "${ip}:/var/www/www/transmission/downloads/" status=$? for i in $(find "./sf/" -name "*.torrent") do rsync -avP --delete-after --progress -e "ssh" "$i" "${ip}:/var/www/www/transmission/torrents/" status=$(( $status + $? )) done fi echo "Ready" if [ "$status" == 0 ]; then sleep 5 process=$(ps x | grep konsole | grep $0 | awk '{print $1}') if [ $(( "$process" + 0 )) -ne 0 ]; then kill $(ps x | grep konsole | grep $0 | awk '{print $1}') fi fi