#---------#---------#---------#---------#---------#---------#---------#---------
# synchronise files using unison and lftp
#
# idc@planetlarg.net 30 jan 2006
#
# synchronise stores of planetlarg content
# memorystick with FAT32 disk (used by both MS Windows and Linux)
# FAT32 disk with web site
#---------#---------#---------#---------#---------#---------#---------#---------
#
# have I left the "hold" lock on the USB store?
OPTIONS=`grep /media/usbdisk /etc/mtab | cut -f4 -d' ' | grep ro`
if [ -n "$OPTIONS" ] 
then 
    echo "can't write to USB store"
    exit 1
fi
#
echo "remount /dev/hda2 with permissions that match /dev/sda1"
# props proving a git
# remount /dev/hda2 (vfat local disk) to match perms on /dev/sda1 (vfat memorystick)
#sudo umount /dev/hda2 || exit 2
#sudo mount -ouid=1000,gid=1000,umask=0077 /dev/hda2 || exit 3
# try 
#    sudo mount -oremount,uid=1000,gid=1000,umask=0077 /dev/hda2
# or
#    sudo mount -ouid=1000,gid=1000,umask=0077 /dev/hda2
#
echo "sync with memory stick"
echo `date` > /tmp/unison.log
#
# image library
  unison -times  -auto -perms 0 -pretendwin -fastcheck true \
    /media/usbdisk/images-idc/  /media/hda2/images-idc/
# docroot
  unison -times  -auto -perms 0 -pretendwin -fastcheck true  \
    /media/usbdisk/bayhosting/ /media/hda2/bayhosting/
#/usr/bin/unison -log -times -auto -prefer newer \
#   /media/usbdisk/user/ /media/hda2/user/ 
#
#/usr/bin/unison -log -times -auto -prefer newer  \
#    /media/usbdisk/images-idc/ /media/hda2/images-idc/ 
#
# remount with proper perms
#echo "remount /dev/hda2 with its default permissions, whatever hotplug decides"
#sudo umount /dev/hda2
#sudo mount /dev/hda2
#
echo "sync with memory stick ok? ready for ftp?"
#
read
echo "sync with web site"
log=/home/issalarg/lftp-planetlarg.log
commands=/home/issalarg/lftp-planetlarg.lftp
echo `date` > $log
/usr/bin/lftp -f $commands
#cat $log
egrep -e 'RETR|STOR' $log
#
#---------#---------#---------#---------#---------#---------#---------#---------

