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