-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·32 lines (27 loc) · 1.09 KB
/
test.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
#!/bin/bash -ue
command -v vagrant >/dev/null 2>&1 || { echo "Command 'vagrant' required but it's not installed. Aborting." >&2; exit 1; }
. config.sh
echo "--- Testing '$BUILD_BOX_NAME' box ..."
if [ -f "$BUILD_OUTPUT_FILE_FINAL" ];
then
echo "--- Suspending any running instances ..."
vagrant suspend
echo "--- Destroying current box ..."
vagrant destroy -f || true
echo "--- Removing '$BUILD_BOX_NAME' ..."
vagrant box remove -f "$BUILD_BOX_NAME" 2>/dev/null || true
echo "--- Adding '$BUILD_BOX_NAME' ..."
vagrant box add --name "$BUILD_BOX_NAME" "$BUILD_OUTPUT_FILE_FINAL"
echo "--- Powerup '$BUILD_BOX_NAME' ..."
vagrant up --no-provision || { echo "Failed to startup '$BUILD_BOX_NAME'. Test failed!"; exit 1; }
echo "--- Suspending '$BUILD_BOX_NAME' ..."
vagrant suspend
else
echo "There is no box file '$BUILD_OUTPUT_FILE_FINAL' in the current directory. Please place the box file here or use './build.sh' to create a box file."
if [ $# -eq 0 ]; then
exit 1 # exit with error when running without param
else
exit 0 # silently exit when running with param
fi
fi
echo "Test passed."