+ # test to see if the remote rdiff backup directory exists and is writable
+ echo "Testing to see if remote rdiff backup directory exists and is writable"
+ ssh $rdiff_user@$rdiff_host "test -d ${rdiff_directory}"
+ if [ $? -eq 0 ]
+ then
+ ssh $rdiff_user@$rdiff_host "test -w $rdiff_directory"
+ if [ $? -ne 0 ]
+ then
+ msgBox "destination directory is not writable!" "The remote destination directory is not writable by the user you specified. Please fix the permissions on the directory and then try again."
+ remote_status=1
+ else
+ remote_status=0
+ fi
+ else
+ booleanBox "Remote directory does not exist" "The destination backup directory does not exist, do you want me to create it for you?"
+ if [ $? = 0 ]
+ then
+ ssh $rdiff_user@$rdiff_host "mkdir -p ${rdiff_directory}"
+ result=$?
+ echo "Hit return to continue."
+ read
+ case $result in
+ 0)
+ msgBox "$rdiff_title: success" "Creation of the remote destination directory was a success!"
+ remote_status=0
+ ;;
+ 1)
+ msgBox "$rdiff_title: error" "Connected successfully to $rdiff_user@$rdiff_host, but was unable to create the destination directory, check the directory permissions."
+ remote_status=1
+ ;;
+ 255)
+ msgBox "$rdiff_title: error" "Failed to connect to $rdiff_user@$rdiff_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host."
+ remote_status=1
+ ;;
+ *)
+ msgBox "$rdiff_title: error" "Unexpected error."
+ remote_status=1
+ ;;
+ esac
+ return
+ fi
+ fi
+
+ if [ $remote_status -ne 1 ]
+ then
+ do_rdiff_con
+ fi
+}
+
+do_rdiff_con() {
+ echo "Testing to make sure destination has rdiff-backup installed and is compatible."
+ remote_result=`/usr/bin/rdiff-backup --test-server $rdiff_user@$rdiff_host::/ 2>&1 >&-`
+ if [ $? -ne 0 ]
+ then
+ echo $remote_result | grep -q "command not found"
+ if [ $? -eq 0 ]
+ then
+ if [ "$rdiff_user" = "root" ]
+ then
+ booleanBox "install rdiff-backup?" "It seems like the remote machine does not have rdiff-backup installed, I can attempt to install rdiff-backup on the remote machine.\n\n\nDo you want me to attempt this now?"
+ if [ $? = 0 ]
+ then
+ ssh $rdiff_user@$rdiff_host 'apt-get install rdiff-backup'
+ result=$?
+ echo "Hit return to continue."
+ read
+ case $result in
+ 0)
+ msgBox "$rdiff_title: success" "Installation of rdiff-backup was a success!"
+ do_rdiff_con
+ ;;
+ 1)
+ msgBox "$rdiff_title: error" "Connected successfully to $rdiff_user@$rdiff_host, but was unable to install the package for some reason."
+ ;;
+ 255)
+ msgBox "$rdiff_title: error" "Failed to connect to $rdiff_user@$rdiff_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host."
+ ;;
+ *)
+ msgBox "$rdiff_title: error" "Unexpected error."
+ ;;
+ esac
+ return
+ fi
+ else
+ booleanBox "install rdiff-backup" "Please install rdiff-backup on the remote machine, this cannot be done automatically, as the remote user in your configuration is not root. \n\nIf you have installed rdiff-backup on the remote machine and you are getting this error, then there is a version incompatibility between that version and the local version.\n\nPlease resolve this problem and then try connecting again.\n\n\n\nTry connecting again?"
+ if [ $? = 0 ]
+ then
+ do_rdiff_con
+ else
+ return
+ fi
+ fi
+ else
+ msgBox "incompatible versions of rdiff-backup" "It looks like rdiff-backup is installed on the remote machine, but it may be an incompatible version with the one installed locally, or something else is amiss.\n\nPlease resolve this problem and then try connecting again.\n\n\nTry connecting again?"
+ if [ $? = 0 ]
+ then
+ do_rdiff_con
+ else
+ return
+ fi
+ fi
+ else
+ echo "SUCCESS: Everything looks good!"
+ echo "Hit return to continue."
+ read
+ fi
+