p-u-comment.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # Copyright © 2016 Emilio Pozuelo Monfort <pochu@debian.org>
  3. # Permission is hereby granted, free of charge, to any person obtaining
  4. # a copy of this software and associated documentation files (the
  5. # "Software"), to deal in the Software without restriction, including
  6. # without limitation the rights to use, copy, modify, merge, publish,
  7. # distribute, sublicense, and/or sell copies of the Software, and to
  8. # permit persons to whom the Software is furnished to do so, subject to
  9. # the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be
  12. # included in all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. set -e
  22. set -u
  23. # Load up some standard variables
  24. export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
  25. . $SCRIPTVARS
  26. . "${configdir}/common"
  27. CMD=(${SSH_ORIGINAL_COMMAND})
  28. COMMAND="${CMD[0]^^}"
  29. QUEUE="${CMD[1]}"
  30. PACKAGE="${CMD[2]}"
  31. case "${QUEUE}" in
  32. p-u-new|o-p-u-new|o-o-p-u-new)
  33. ;;
  34. *)
  35. echo "Invalid policy queue ${QUEUE}."
  36. exit 42
  37. ;;
  38. esac
  39. case "${COMMAND}" in
  40. ACCEPT|REJECT)
  41. ;;
  42. *)
  43. echo "Invalid command ${COMMAND}."
  44. exit 42
  45. ;;
  46. esac
  47. destdir=${queuedir}/${QUEUE}/COMMENTS/
  48. cd $destdir
  49. echo "Importing new ${COMMAND} comment file for ${PACKAGE} into ${QUEUE}"
  50. trap cleanup EXIT
  51. tmpfile=$( gettempfile )
  52. destfile=${COMMAND}.${PACKAGE}
  53. cat > ${tmpfile}
  54. chmod a+r ${tmpfile}
  55. mv ${tmpfile} ${destfile}
  56. echo "Done"
  57. exit 0