forked from projectatomic/atomic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagrant.sh
60 lines (50 loc) · 1.41 KB
/
vagrant.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -euo pipefail
_FINISH(){
RESULT=($?)
if [ ${RESULT} -eq 0 ]; then
echo ""
echo "Tests completed normally..."
vagrant destroy ${BOX}
echo ""
else
echo ""
echo "** Test failed. Leaving '${BOX}' running for debug." 2>&1 | tee -a ${tee_file}
echo "** Be sure to halt or destroy prior to re-running the check" 2>&1 | tee -a ${tee_file}
echo "** Logs are stored at ${tee_file}"
echo ""
exit 1
fi
}
# When make calls bash, the real signals are not surfaced
# correctly to trap. So we trap on EXIT and then sort it
# out in _FINISH
trap _FINISH EXIT
BOXES="fedora_atomic centos_atomic fedora_cloud"
is_running() {
status=$(vagrant status | grep ${BOX} | awk '{print $2}')
if [ ${status} == "running" ]; then
RUNNING=true
else
RUNNING=false
fi
}
if [[ ! $BOXES =~ $BOX ]]; then
echo ""
echo "Invalid BOX name: $BOX. Valid choices are $BOXES"
echo ""
exit 1
fi
echo "Testing on ${BOX}"
timestamp=$(date +%Y_%m_%d_%H_%M)
tee_file="${BOX}_${timestamp}.log"
is_running
if ${RUNNING}; then
echo ""
echo "*** '${BOX}' is already running. Re-syncing and rerunning test ..."
echo ""
vagrant rsync ${BOX}
else
vagrant up ${BOX} 2>&1 | tee ${tee_file}
fi
vagrant ssh ${BOX} -c "cd /home/vagrant/atomic && sudo sh ./.papr.sh" 2>&1 | tee -a ${tee_file}