#!/bin/bash
#push this stuff up
zencmd='zenity --title="sync up"'


syncup()
{ 
    if [ ! -e $1 ]; then
      return
    fi
    if [ -z "$3" ]; then
        exclude=""
    else
        exclude="--exclude=$3"
    fi
    echo $1
    rsync -avzH --delete $exclude -e "$sshcmd" $1 $rsyncpath/$2 | $zencmd --text="syncing $1 to $rsyncpath/$2" --progress --pulsate --auto-close
        
}

username=`$zencmd --entry --text="Username" --entry-text=$USER` 
hostname=`$zencmd --entry --text="Hostname" --entry-text=fedorapeople.org`
homedir=`$zencmd --entry --text="enter remote homedirectory full path" --entry-text=/home/fedora/$username/roam`

SSH_ASKPASS='/usr/libexec/openssh/gnome-ssh-askpass'


rsyncpath="$username@$hostname:$homedir"
sshcmd="ssh -o 'ControlPath /dev/shm/%h%r' -o 'ControlMaster auto'"

eval $sshcmd -MNf ${username}@${hostname}

syncup ~/.ssh/ .ssh
syncup ~/.gconf/ .gconf
syncup ~/.liferea_1.2/ .liferea_1.2 *Cache*
syncup ~/.mozilla/ .mozilla *Cache*
syncup ~/.gnome2/ .gnome2 *ache*
syncup ~/.gnome/ .gnome *ache*
syncup ~/.gtkrc
syncup ~/.gtkrc-1.2-gnome2
syncup ~/.tomboy/ .tomboy
syncup ~/.xchat2/ .xchat2
$zencmd --info --text="Your files are now synced up"
eval $sshcmd ${username}@${hostname} -O exit

