moveftp.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. set -e
  3. set -u
  4. QUEUEHOSTS="queue-coccia"
  5. FTPDIR="/srv/upload.debian.org/ftp/pub/UploadQueue/"
  6. SSHDIR="/srv/upload.debian.org/UploadQueue/"
  7. PROCESSDELAYED=1
  8. HOST=$(hostname -s)
  9. # Only one of me should ever run.
  10. FLOCKER=${FLOCKER:-""}
  11. [[ ${FLOCKER} != $0 ]] && exec env FLOCKER="$0" flock -E 0 -en "$0" "$0" "$@" || :
  12. # For usper, targetdir is the sshdir, everywhere else, its a separate
  13. # one, so we avoid fetching partial uploads from their sshdir.
  14. if [[ ${HOST} == usper ]]; then
  15. TARGETDIR="${SSHDIR}"
  16. TOPROCESS="${FTPDIR}"
  17. elif [[ ${HOST} == suchon ]]; then
  18. TARGETDIR=/srv/security.upload.debian.org/SecurityUploadQueue/
  19. TOPROCESS=/srv/security.upload.debian.org/ftp/pub/SecurityUploadQueue/
  20. PROCESSDELAYED=
  21. else
  22. TARGETDIR="/srv/upload.debian.org/mergedtree"
  23. TOPROCESS="${FTPDIR} ${SSHDIR}"
  24. fi
  25. # This runs on all queue hosts - merge ftp and ssh together. (The queued on usper only processes
  26. # the TARGETDIR)
  27. for sourcedir in ${TOPROCESS}; do
  28. find ${sourcedir} -maxdepth 1 -type f -mmin +5 -print0 -exec mv --no-clobber --target-directory=${TARGETDIR} -- "{}" +
  29. if [[ -n "${PROCESSDELAYED}" ]]; then
  30. for defdir in {0..15}; do
  31. find ${sourcedir}/DELAYED/${defdir}-day -maxdepth 1 -type f -mmin +5 -print0 -exec mv --no-clobber --target-directory=${TARGETDIR}/DELAYED/${defdir}-day -- "{}" +
  32. done
  33. fi
  34. done
  35. # If we are the master host, we have a little extra work to do, collect all
  36. # files from other queue hosts.
  37. if [[ ${HOST} == usper ]]; then
  38. # And now fetch all files from the queue hosts
  39. cd ${SSHDIR}
  40. for host in ${QUEUEHOSTS}; do
  41. rsync -aOq --ignore-existing --remove-source-files -e 'ssh -F /srv/ftp-master.debian.org/dak/config/homedir/ssh/usper-config' ${host}:/does/not/matter . || true
  42. done
  43. fi