dcs-package-importer: don’t add a leading / to the index
[debiancodesearch.git] / verify-new-files.sh
blobb16102824af2a162c1c0cdf0ed223fdbcbb07122
1 #!/bin/zsh
3 set -e
5 # Bring up a new batch stack. We overwrite the -max_stacks flag: by default it
6 # is 5. This way, we can always bring up a batch stack, even if there are 5
7 # batch queries running currently.
8 STACK=$(dcs-batch-helper -max_stacks=6 create)
9 if [ $? -ne 0 ]
10 then
11 echo "Could not create a new batch stack" >&2
12 exit 1
15 # Now point the source-backend to /dcs/unpacked-new instead of /dcs/unpacked.
16 EXECSTART=$(perl -nlE 'say if /^ExecStart=.*[^\\]$/ || /^ExecStart=/ .. /[^\\]$/' < /run/systemd/system/dcs-batch${STACK}-source-backend.service | sed 's,/dcs/unpacked,/dcs/unpacked-new,g')
18 mkdir /run/systemd/system/dcs-batch${STACK}-source-backend.service.d
19 cat >/run/systemd/system/dcs-batch${STACK}-source-backend.service.d/args.conf <<EOT
20 [Service]
21 ExecStart=
22 ${EXECSTART}
23 EOT
25 systemctl daemon-reload
26 systemctl restart dcs-batch${STACK}-source-backend.service
28 # And point the index-backends to /dcs/NEW/*.idx instead of /dcs/*.idx
29 EXECSTART=$(perl -nlE 'say if /^ExecStart=.*[^\\]$/ || /^ExecStart=/ .. /[^\\]$/' < /run/systemd/system/dcs-batch${STACK}-index-backend@.service | sed 's,/dcs/index,/dcs/NEW/index,g')
30 for backend in $(systemctl list-units --full | grep "^dcs-batch${STACK}-index-backend" | cut -f 1 -d ' ')
32 mkdir /run/systemd/system/${backend}.d
33 cat >/run/systemd/system/${backend}.d/args.conf <<EOT
34 [Service]
35 ExecStart=
36 ${EXECSTART}
37 EOT
38 systemctl daemon-reload
39 systemctl restart $backend
40 done
42 # TODO: remove this once dcs-web is socket-activated.
43 sleep 10
45 # Verify the new files are okay.
46 # As we discover problems, more checks could be added here, but this one seems fine for now.
47 if ! wget -qO- "http://localhost:30${STACK}20/search?q=i3Font" | grep -q 'i3Font load_font'
48 then
49 echo "Stack not serving correctly, /search?q=i3Font did not contain 'i3Font load_font'" >&2
50 exit 1
53 # Delete the drop-ins and destroy the batch stack.
54 rm -rf /run/systemd/system/dcs-batch${STACK}-source-backend.service.d
55 for backend in $(systemctl list-units --full | grep "^dcs-batch${STACK}-index-backend" | cut -f 1 -d ' ')
57 rm -rf /run/systemd/system/${backend}.d
58 done
60 dcs-batch-helper destroy $STACK