-
-
Notifications
You must be signed in to change notification settings - Fork 157
Tombautosyncviasshfs
boyska edited this page Feb 11, 2012
·
30 revisions
######################DISCLAIMER######################
THE CODE IN THIS PAGE IS HORRIBLE AND DISGUSTING!!!
READ TI JUST IF YOU UNDERSTAND IT AND YOU WANT TO DEBUG
######################################################
###Scenario
We have two laptop: a big one and a netbook and we need to share a tomb with personal settings and data.
###Description
unfortunately, we can't just use a "shared" tomb, because tomb cannot be mounted by more than one computer. Furthermore, tomb has (still) no way to use a lock. So, we need to do it ourselves with an external lock (just aside to the tomb).
What we do is (periodically):
###The HORRIBLE code
####### START SESSION SCRIPT
export imgpath=`zenity --file-selection --text='Seleziona il file da cui estrarre la chiave' --title='Seleziona un file immagine'`
tomb exhume $imgpath /tmp/local.tomb
if ! tomb open /path/to/local.tomb -k /tmp/local.tomb.key; then
wipe -f -s /tmp/local.tomb.key
zenity --error --text='Non sono riuscito a montare la tomba!' --title='Orrore!'
return 1
fi
zenity --notification --text='Tomba locale montata correttamente'
if sshfs remote.server:/ /local/mountpoint/; then
tomb open /local/mountpoint/remote.tomb -k /tmp/remote.tomb.key
wipe -f -s /tmp/local.tomb.key
zenity --notification --text=zenity --notification --text='Tomba remota montata correttamente'
else
wipe -f -s /tmp/local.tomb.key
zenity --error --text='Non riesco a raggiungere il server remoto!' --title='Orrore!'
return 1
fi
###### POST-HOOK
remotetomb="/media/remote.tomb/"
localtomb="/media/local.tomb/"
lockfile="/local/mountpoint/tomb.lock"
(flock 5
if tomb list $remotetomb;then #se la tomba e' montata
if unison $remotetomb $localtomb;then
zenity --notification --text='Dati sincronizzati con successo' --title='Ok!'
else
zenity --error --text='Non sono riuscito a sincronizzare i dati!' --title='Orrore!'
return 1
fi
else
zenity --error --text='La tomba remota non è montata!' --title='Orrore!'
fi
) 5> $lockfile