-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvagrant
executable file
·43 lines (34 loc) · 1.1 KB
/
vagrant
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
#!/bin/bash -l
usage(){
echo ""
echo "This script executes vagrant commands with parameter"
echo "USAGES:"
echo " \$ $(basename $0) <sub_command> [Vagrantfile name]"
echo " <sub_command> up, ssh, halt, destroy"
echo " e.g.)"
echo " $(basename $0) up ==> execute \"vagrant up\" with default Vagrantfile"
echo " $(basename $0) up vagrant.22.04.Vagrantfile ==> execute \"vagrant up\" with Vagrantfile for 22.04"
exit 1
}
if [[ "$#" -ge 3 || "$#" -eq 0 ]]; then
usage;
fi
# ASSIGN PARAMETERS
SUB_CMD=$1
if [[ "${SUB_CMD}" != "up" && "${SUB_CMD}" != "ssh" && "${SUB_CMD}" != "halt" && "${SUB_CMD}" != "destroy" ]]; then
usage;
fi
if [[ "$#" == "2" ]]; then
CONFIG_FILE=$2
if [ ! -f ${CONFIG_FILE} ]; then
echo "Not found the related configuration file"
exit 1;
fi
fi
if [[ "${CONFIG_FILE}" != "" ]]; then
export VAGRANT_VAGRANTFILE=${CONFIG_FILE}
export VAGRANT_DOTFILE_PATH=.vagrant_${CONFIG_FILE}
echo "VAGRANT_VAGRANTFILE = ${VAGRANT_VAGRANTFILE}"
echo "VAGRANT_DOTFILE_PATH= ${VAGRANT_DOTFILE_PATH}"
fi
vagrant ${SUB_CMD}