forked from fideloper/Vaprobash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpb
executable file
·52 lines (43 loc) · 1.12 KB
/
vpb
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
#!/usr/bin/env bash
#
# This file acts as something of a front controller. It defines the
# environment for the framework and loads all the libraries before
# palming off the workload to the router (vpb.router).
#
if [ -n "$VPB_TRACE" ] ; then
set -ue
trace() {
typeset -i i=0
for func in "${FUNCNAME[@]}"
do
printf '%24s() %s:%d\n' "$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[$i]}"
let i++ || true
done
}
trap 'echo "Unexpected error at: line $LINENO"; trace; exit' ERR EXIT
exit() {
trap - ERR EXIT
command exit "$@"
}
fi
vpb() {
# Detect if we are within the VM or not
if [ -d /vagrant ] ; then
VPB_IN_VM="yes"
fi
# Setup base path
# TODO: This should be capable of being more dynamic
if [ -d /vagrant ] ; then
VPB_ROOT=/vagrant/.vpb
else
VPB_ROOT=./.vpb
fi
# Source the libs
. ${VPB_ROOT}/lib/usage.sh
. ${VPB_ROOT}/lib/util.sh
. ${VPB_ROOT}/lib/pkg.sh
. ${VPB_ROOT}/lib/controller.sh
. ${VPB_ROOT}/lib/router.sh
vpb.router $@
}
vpb $@