-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·156 lines (135 loc) · 3.65 KB
/
install.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env bash
#reset seconds variable
SECONDS=0
source ./scripts/constants.sh
#spin up proxy machine
#compress scripts folder
rm -rf scripts.tar.gz
tar -zcf scripts.tar.gz ./scripts
# start vagrant and provision virtual machine
chmod -R 0777 ~/.vagrant.d
SHELL_ARGS=''
snapshot_name=""
append_to_snapshot_name()
{
new_name=$1
if [[ "$snapshot_name" -eq "" ]]
then
snapshot_name=$new_name
else
snapshot_name="$snapshot_name-$new_name"
fi
}
unset VAGRANT_USE_SQUID_PROXY_VM
while getopts 'sagtcjudrpbg:' flag; do
case $flag in
s)
revert_to_last_snapshot="true"
;;
p)
#use proxy vm
use_proxy_vm="true"
;;
a)
#install TeamCity
append_to_snapshot_name "install_teamcity_agent"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-a '
;;
c)
#install TeamCity Agent
append_to_snapshot_name "install_teamcity"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-c '
;;
g)
#refresh dendro config file only
append_to_snapshot_name "refresh_configs_only"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-g '
;;
t)
#Run Tests on Dendro after checkout
append_to_snapshot_name "run_tests"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-t '
;;
r)
#refresh only the code of Dendro without installing dependencies
append_to_snapshot_name "refresh_code_only"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-r '
;;
d)
#enable development mode
append_to_snapshot_name "set_dev_mode"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-d '
;;
u)
#disable development mode
append_to_snapshot_name "unset_dev_mode"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-u '
;;
j)
#Install Jenkins
append_to_snapshot_name "install_jenkins"
VAGRANT_SHELL_ARGS=$VAGRANT_SHELL_ARGS'-j '
;;
b)
#Checkout Dendro branch specified as argument
append_to_snapshot_name "install_with_branch_$OPTARG"
VAGRANT_SHELL_ARGS="$VAGRANT_SHELL_ARGS-b $OPTARG "
;;
*)
error "Unexpected option $flag"
;;
esac
done
if [[ "$revert_to_last_snapshot" = "true" ]]
then
#revert to last snapshot
warning "Reverting to last snapshot before proceeding with operations...."
snapshot_id=$(VBoxManage snapshot $active_deployment_setting list | tail -n 1 | grep -o "UUID.*" | cut -c 7-42)
source ./halt_vm.sh
VBoxManage snapshot $active_deployment_setting restore $snapshot_id
else
take_vm_snapshot $active_deployment_setting $snapshot_name
fi
if [[ "$use_proxy_vm" == "true" ]]; then
git clone https://github.com/zephod/squid-vagrant-server.git proxy-vm
cd proxy-vm
vagrant up
cd -
export VAGRANT_USE_SQUID_PROXY_VM="true"
fi
source ./define_env_vars.sh
export VAGRANT_VM_INSTALL='true'
info "Running vagrant halt..."
vagrant halt -f
#create shared folders if they dont exist already
if [[ ! -d "shared_folders/dendro" ]]
then
mkdir -p "shared_folders/dendro"
fi
if [[ ! -d "shared_folders/etc/init.d" ]]
then
mkdir -p "shared_folders/etc/init.d"
fi
info "Running vagrant up..."
#vagrant box update
if [ "$JENKINS_BUILD" == "1" ]
then
#export VAGRANT_LOG="info"
#OLD_SSH_AUTH_SOCK=$SSH_AUTH_SOCK
#SSH_AUTH_SOCK=""
vagrant up --provider virtualbox --provision ||
die "There were errors installing Dendro."
#SSH_AUTH_SOCK=$OLD_SSH_AUTH_SOCK
#unset VAGRANT_LOG
else
vagrant up --provider virtualbox --provision ||
die "There were errors installing Dendro."
fi
info "Cleaning up..."
rm ./scripts.tar.gz
success "Deleted temporary scripts package."
#print time elapsed
duration=$SECONDS
info "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
#clean list of VMs
#sudo vagrant global-status --prune