-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·307 lines (240 loc) · 9.64 KB
/
build.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#!/bin/bash
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'FreeBSD' ]]; then
which -s brew
if [[ $? != 0 ]] ; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
else
brew update
fi
for pkg in dialog; do
if brew list -1 | grep -q "^${pkg}\$"; then
echo "Package '$pkg' is installed"
else
echo "Package '$pkg' is not installed"
fi
done
elif [[ "$unamestr" == 'Linux' ]]; then
echo "Good Job Running Linux "
fi
INPUT=/tmp/menu.sh.$$
OUTPUT=output.log
vi_editor=${EDITOR-vi}
trap "rm $OUTPUT; rm $INPUT; exit" SIGHUP SIGINT SIGTERM
function start_vm() {
dialog --backtitle "Starting VM!"\
--title "Starting......" --clear \
--infobox "please wait while vm starts. :)" 40 90
vagrant up
dialog --backtitle "VM Starting"\
--title "VM Starting"\
--msgbox "$(cat output.log)" 40 90
}
function stop_vm() {
dialog --backtitle "Stopping VM!"\
--title "Stopping......" --clear \
--infobox "please wait while vm stops. :)" 40 90
vagrant halt
dialog --backtitle "VM Stopping"\
--title "VM Stopping"\
--msgbox "$(cat output.log)" 40 90
}
function restart_vm() {
dialog --backtitle "Reloading VM!"\
--title "Reloading......" --clear \
--infobox "please wait while vm reloads. :)" 40 90
vagrant reload
dialog --backtitle "VM Reloading"\
--title "VM Reloading"\
--msgbox "$(cat output.log)" 40 90
}
function install_vagrant_plugins() {
dialog --backtitle "Installing Vagrant Plugins Please be patient!"\
--title "Installing......" --clear \
--infobox "please wait while the plugins are installed the job will start once you\
close this window. :)" 40 90
vagrant plugin install vagrant-vbguest 2>&1 | tee output.log
dialog --backtitle "Installing Vagrant Plugins"\
--title "Finished Installation!"\
--msgbox "$(cat output.log)" 40 90
}
function install_intellij() {
dialog --backtitle "Installing VM With Intellij Please be patient!"\
--title "Installing......" --clear\
--infobox "please wait while the vm is built and installed the job will start once you\
close this window.\n there is a log that you can view when it is finished. \n \
this can take a long time. be patient. :)" 40 90
export FACTER_options='intellij';
vagrant up 2>&1 | tee output.log
vagrant reload
dialog --backtitle "Installing VM With Intellij COMPLETED!!"\
--title "Finished Installation!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function install_Kubernetes() {
dialog --backtitle "Installing VM With kubernetes Please be patient!"\
--title "Installing kubernetes......" --clear\
--infobox "please wait while the vm is built and installed the job will start once you\
close this window.\n there is a log that you can view when it is finished. \n \
this can take a long time. be patient. :)" 40 90
export FACTER_options='kubernetes';
vagrant up 2>&1 | tee output.log
vagrant reload
dialog --backtitle "Installing VM With kubernetes COMPLETED!!"\
--title "Finished kubernetes Installation!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function add_Kubernetes() {
dialog --backtitle "Installing VM With kubernetes Please be patient!"\
--title "Installing kubernetes......" --clear\
--infobox "please wait while the vm is built and installed the job will start once you\
close this window.\n there is a log that you can view when it is finished. \n \
this can take a long time. be patient. :)" 40 90
vagrant reload
export FACTER_options='kubernetes';
vagrant provision 2>&1 | tee output.log
vagrant reload
dialog --backtitle "Installing VM With panamax COMPLETED!!"\
--title "Finished Installation!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function add_intellij() {
dialog --backtitle "Installing VM With Intellij Please be patient!"\
--title "Installing......" --clear\
--infobox "please wait while the vm is built and installed the job will start once you\
close this window.\n there is a log that you can view when it is finished. \n \
this can take a long time. be patient. :)" 40 90
sed -e 's/gui = false/gui = true/g' Vagrantfile
sed -e 's/#brackURL/URL/g' Vagrantfile
vagrant reload
export FACTER_options='intellij';
vagrant provision 2>&1 | tee output.log
vagrant reload
dialog --backtitle "Installing VM With Intellij COMPLETED!!"\
--title "Finished Installation!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function install() {
dialog --backtitle "Base VM Install Please be patient!"\
--title "Installing......" --clear\
--infobox "please wait while the vm is built and installed the job will start once you\
close this window.\n there is a log that you can view when it is finished. \n \
this can take a long time. be patient. :)" 40 90
sed -e 's/gui = true/gui = false/g' Vagrantfile
export FACTER_options='none';
vagrant up 2>&1 | tee output.log
vagrant reload
dialog --backtitle "Base Install COMPLETED!!"\
--title "Finished Installation!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function cleanInstall() {
dialog --backtitle "Cleaning up install deleting VM Please be patient!"\
--title "Installing......" --clear\
--infobox "please wait while the vm is destroyed the job will start once you close\
this window.\n there is a log that you can view when it is finished. \n \
this can take a long time. be patient. :)" 40 90
vagrant destroy --force 2>&1 | tee output.log
dialog --backtitle "Clean Install COMPLETED!!"\
--title "Finished Cleanup!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function InstallLocalKubernetes() {
dialog --backtitle "Cleaning up install deleting VM Please be patient!"\
--title "Installing......" --clear\
--infobox "Setting up your Kubernetes install in /opt :)" 40 90
URL='https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_64.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && sudo dpkg -i $FILE; rm $FILE
git clone https://github.com/GoogleCloudPlatform/kubernetes.git /opt/kubernetes
cd /opt/kubernetes
export KUBERNETES_NUM_MINIONS=3
vagrant up
dialog --backtitle "Kubernetes Install COMPLETED!!"\
--title "Finished Install!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function InstallLocalPanamax() {
dialog --backtitle "Cleaning up install deleting VM Please be patient!"\
--title "Installing panamax locally" --clear\
--infobox "This installs Along With The Development VM" 40 90
if [ "$(expr substr $(uname -s) 1 5)" == "Darwin" ]; then
which -s brew
if [[ $? != 0 ]] ; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
else
brew update
fi
if brew list -1 | grep -q "^panamax\$"; then
echo "Package 'panamax' is installed!"
else
brew install http://download.panamax.io/installer/brew/panamax.rb
echo "Package 'panamax' is now installed"
fi
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
echo "Supporting Ubuntu Linux only for now."
sudo apt-get install unzip -y --force-yes
URL='https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_64.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && sudo dpkg -i $FILE; rm $FILE
curl http://download.panamax.io/installer/ubuntu.sh | bash
fi
panamax init
dialog --backtitle "Clean Install COMPLETED!!"\
--title "Finished Cleanup!" --clear\
--msgbox "$(cat output.log)" 40 90
}
function LinkToDevelopmentProject() {
dialog --backtitle "Creating a Development Env link"\
--title "Create a Link" --clear\
--infobox "Creating a link to your local project. If you want to work on your project or use the code from your local project; inside the vm, this is the place to be." 40 90
dialog --inputbox "The Full path to the directory of your project:" 8 40 2>/tmp/input.$$
path=`cat /tmp/input.$$`
dialog --backtitle "Linking..." --title "Creating a Link" --infobox "creaing link to: ${path}" 40 90
ln -s $path `pwd`/development
dialog --backtitle "Linking COMPLETED!!" --title "Finished !" --msgbox "$(ls -alh `pwd`/development)" 40 90
echo "RELOADING VM"
vagrant reload
}
function viewlogs() {
dialog --textbox output.log 40 120
}
while true
do
dialog --clear --colors --help-button --backtitle "Linux Shell Script Tutorial" \
--title "[ D R U P A L D E P L O Y - M E N U ]" \
--menu "Welcome to the drupal deploy system \n\
The log is stored in /tmp/n \
use letter of the choice as a hot key, or the \
number keys 1-9 to choose an option.\n\n\
Choose from the options below" 25 80 30 \
StartVM "After you've installed use this to start" \
StopVM "Use this to shutdown your VM until later" \
RestartVM "Restart the VM this way remaps the synced folders" \
VagrantPlugins "Install the virtualbox guest additions manager" \
VMInstall "install vm with base options <HEADLESS>" \
Clean "Wipe out all the things and start fresh" \
Intellij "install vm with intellij" \
provisionIntellij "provision vm with intellij" \
EditVagrantfile "Edit the Vagrantfile" \
LinkToDevelopmentProject "Link to your local projet directory" \
ViewLog "View the installer log" \
SaveLog "View the installer log" \
Exit "Exit to the shell" 2>"${INPUT}"
menuitem=$(<"${INPUT}")
case $menuitem in
StartVM) start_vm;;
StopVM) stop_vm;;
RestartVM) restart_vm;;
VagrantPlugins) install_vagrant_plugins;;
Intellij) install_intellij;;
provisionIntellij) add_intellij;;
VMInstall) install;;
Clean) cleanInstall;;
EditVagrantfile) $vi_editor Vagrantfile;;
LinkToDevelopmentProject) LinkToDevelopmentProject;;
ViewLog) viewlogs;;
SaveLog) cp $OUTPUT ./SavedLog.log;;
Exit) echo "Leaving the installer"; break;;
esac
done
# if temp files found, delete em
[ -f $OUTPUT ] && rm $OUTPUT
[ -f $INPUT ] && rm $INPUT