summaryrefslogtreecommitdiffstats
path: root/fetch-autobuild.sh
blob: 82a5a3fe4b3be1e3d70832555f52db9a869d4ea3 (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
#!/bin/bash

IN_PROGRESS=$(ssh -o ConnectTimeout=10 autobuild cat /home/iurt/autobuild-logs/IN-PROGRESS 2>/dev/null)

if [ -n "$IN_PROGRESS" ]; then
	rsync -qa autobuild:/home/iurt/autobuild-logs/${IN_PROGRESS}/log/ /var/www/bs/autobuild/cauldron/aarch64/core/${IN_PROGRESS}/
else
	LAST=$(ssh -o ConnectTimeout=10 autobuild cat /home/iurt/autobuild-logs/LAST 2>/dev/null)
	if [ -n "$LAST" ]; then
		# Maybe the machine just booted beween getting IN_PROGRESS and LAST, so ensure IN_PROGRESS is really not there
		IN_PROGRESS=$(ssh -o ConnectTimeout=10 autobuild cat /home/iurt/autobuild-logs/IN-PROGRESS 2>/dev/null)
		if [ -n "$IN_PROGRESS" ]; then
			exit
		fi
		LAST_CHANGE=$(ssh -o ConnectTimeout=10 autobuild stat -c %Y /home/iurt/autobuild-logs/${LAST}/log/status.core.log)
		LOCAL_CHANGE=$(stat -c %Y /var/www/bs/autobuild/cauldron/aarch64/core/${LAST}/status.core.log)
		if [ "$LOCAL_CHANGE" != "$LAST_CHANGE" ]; then
			rsync -qa autobuild:/home/iurt/autobuild-logs/${LAST}/log/ /var/www/bs/autobuild/cauldron/aarch64/core/${LAST}/
		fi
		if [ $(readlink /var/www/bs/autobuild/cauldron/aarch64/core/latest) != ${LAST} ]; then
			pushd /var/www/bs/autobuild/cauldron/aarch64/core/
			rm -f latest; ln -s ${LAST} latest
			#~/cleanlogs.sh $(\ls -d 2* | tail -n 13 | head -n 10)
			popd
			echo "Autobuild finished at $(stat -c %y /var/www/bs/autobuild/cauldron/aarch64/core/${LAST}/status.core.log)"
			sed -i -e 's/\x00*//' /var/www/bs/autobuild/cauldron/aarch64/core/${LAST}/status.core.log
			ruby autobuild2.rb insert /var/www/bs/autobuild/cauldron/aarch64/core/${LAST}/status.core.log
			ruby autobuild2.rb report /var/www/bs/autobuild/
		fi
	fi
fi