BASH   30

rsync

Guest on 23rd April 2022 12:43:09 AM

  1. #! /bin/sh  
  2.  
  3. #
  4. # Rsync script
  5. # Copyright DVL Software Limited
  6. #
  7. # Available from http://www.freebsddiary.org/samples/rsync.txt
  8.  
  9. if ! export PREFIX=$(expr $0 : "\(/.*\)/etc/rsync/update\.sh\$"); then
  10.     echo "$0: Cannot determine the PREFIX" >&2
  11.     exit 1
  12. fi
  13.  
  14. export PATH=/bin:/usr/bin:${PREFIX}/bin
  15.  
  16. lock=/var/spool/lock/rsync.lock
  17. log=/var/log/rsync.log
  18.  
  19. # Rotate the log files
  20.  
  21. umask 22
  22. test -f ${log}.7 && mv -f ${log}.7 ${log}.8
  23. test -f ${log}.6 && mv -f ${log}.6 ${log}.7
  24. test -f ${log}.5 && mv -f ${log}.5 ${log}.6
  25. test -f ${log}.4 && mv -f ${log}.4 ${log}.5
  26. test -f ${log}.3 && mv -f ${log}.3 ${log}.4
  27. test -f ${log}.2 && mv -f ${log}.2 ${log}.3
  28. test -f ${log}.1 && mv -f ${log}.1 ${log}.2
  29. test -f ${log}.0 && mv -f ${log}.0 ${log}.1
  30. test -f ${log}   && mv -f ${log}   ${log}.0
  31. exec >${log} 2>&1
  32.  
  33. # Do the update
  34.  
  35. date "+rsync update begins at %Y/%m/%d %H:%M:%S"
  36.  
  37. # The rest of this is executed while holding the lock file, to ensure that
  38. # multiple instances won't collide with one another.
  39.  
  40. lockf -t 0 ${lock} /bin/sh << 'E*O*F'
  41.  
  42. base=${PREFIX}/etc/rsync
  43. cd ${base} || exit
  44. . ./config.sh || exit
  45.  
  46. colldir=sup.client
  47. startup=${PREFIX}/etc/rc.d
  48.  
  49. umask 2
  50.  
  51. echo ""
  52. echo "Updating from ${host} - 3.0-RELEASE"
  53. rsync -av --stats ${host}::freebsd/releases/3.0-RELEASE         /pub/ftp/pub/FreeBSD/releases/
  54.  
  55. echo "========================================"
  56. echo ""
  57. echo "Updating from ${host} - 2.2.8-RELEASE"
  58. rsync -av --stats ${host}::freebsd/releases/2.2.8-RELEASE       /pub/ftp/pub/FreeBSD/releases/
  59.  
  60. echo "========================================"
  61. echo ""
  62. echo "Updating from ${host} - XFree86"
  63. rsync -av --stats ${host}::freebsd/releases/XFree86             /pub/ftp/pub/FreeBSD/releases/
  64.        
  65. echo "========================================"
  66. echo ""
  67. echo "Updating from ${host} - tools "    
  68. rsync -av --stats ${host}::freebsd/tools                        /pub/ftp/pub/FreeBSD/tools    
  69.  
  70. echo "========================================"
  71. echo ""
  72. echo "Updating from ${host} - CERT"        
  73. rsync -av --stats ${host}::freebsd/CERT                         /pub/ftp/pub/FreeBSD/        
  74.  
  75. E*O*F                                          
  76.        
  77. date "+rsync update ends at %Y/%m/%d %H:%M:%S"

Raw Paste


Login or Register to edit or fork this paste. It's free.