Skip to content
Snippets Groups Projects
esamesync-esame.sh 1.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • #!/bin/bash
    #/usr/local/sbin/esamesync-esame.sh
    
    # Host for the sync operation
    
    # (A different value can be specified in /etc/sysconfig/esamesync-esame)
    
    ESAMESYNCHOST=master2.edu-al.unipmn.it
    
    
    # Max delay in case of errors (a random delay will be used, calculated
    # between 0 and this value).
    # (A different value can be specified in /etc/sysconfig/esamesync-esame)
    MAXSLEEP=30
    
    
    # Configuration override can go to:
    . /etc/sysconfig/esamesync-esame
    
    /usr/local/bin/bta-netwait ${ESAMESYNCHOST}
    
    /bin/cat <<MSG
    Starting /opt/esame syncronization (if it seems to be stuck, please wait for
    a few minutes for your updates to take place; they can require a long time)
    
            DON'T TURN OFF THIS MACHINE NOW, JUST WAIT UNTIL FINISHED
    
    MSG
    
    DST=/opt/esame/
    SRC=rsync://${ESAMESYNCHOST}/opt/esame/
    
    cd ${DST}
    
    # To fix spurious errors, we pause and repeat the sync if necessary.
    # Note: excluding /opt/google as that is installed locally with RPMs.
    # Note: excluding /opt/esame as it is already syncronized on every boot.
    #
    
    while ! rsync -avq --sparse --progress --delete --whole-file ${SRC} . ; do
          SLEEPTIME="$(expr $RANDOM % $MAXSLEEP)"
          echo "Error from rsync, sleeping for ${SLEEPTIME} seconds."
          sleep ${SLEEPTIME}