summaryrefslogtreecommitdiff
path: root/metadata/scripts/update-and-validate.sh
blob: 0bd5050d53165431f7b932805d991f0250213e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# Used on metadata.swamid.se and metadata.lab.swamid.se

update()
{
	mkdir -p .time

	# Remove old entitys from DB
	ls swamid-edugain/*.xml swamid-2.0/*.xml | sed 's@swamid-.*/\(.*\).xml@.time/\1.validate@' | sort > /tmp/$$.xml
	ls .time/*.validate > /tmp/$$.time
	comm -13 /tmp/$$.xml /tmp/$$.time | while read file; do
		docker exec ${CONTAINER} /var/www/scripts/removeEntity.bash /opt/metadata/$file
	done
	rm /tmp/$$.xml /tmp/$$.time

	# Update/Import "new" xml-files
	make -f ${MAKE} -s

	# Revalidate entities in prod not validated for the last nr of days
	docker exec ${CONTAINER} php /var/www/scripts/revalidate.php 14 10

	# check URL:s 
	docker exec ${CONTAINER} php /var/www/scripts/checkURLs.php

	# update TestResults from release-check -> DB
	docker exec ${CONTAINER} php /var/www/scripts/updateTestResults.php

	# Cleanup Pending-queue
	docker exec ${CONTAINER} php /var/www/scripts/cleanupPending.php

	# to be able to show non-swamid entities on web-page
	wget -qO swamid-2.0.xml https://mds.swamid.se/md/swamid-2.0.xml
	docker exec ${CONTAINER} php /var/www/scripts/updateExternalEntities.php
}

CONTAINER="swamid-metadata-sp"
MAKE="Make.validate"

if [ "$(lsb_release -i -s)" = "Debian" ]; then
  CONTAINER="metadata-sp-metadata-sp-1"
  MAKE="Makefile.validate-debian"
fi

cd /opt/metadata || exit 1
update