-
Notifications
You must be signed in to change notification settings - Fork 31
/
desktop
executable file
·618 lines (558 loc) · 21.8 KB
/
desktop
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
#!/bin/bash
BASEBOX_DEFAULT="panamax-coreos-box-681.2.0"
BASEBOX_URL_DEFAULT="http://stable.release.core-os.net/amd64-usr/681.2.0/coreos_production_vagrant.box"
PMX_IMAGE_TAG_DEFAULT=stable
PMX_UI_TAGS="https://index.docker.io/v1/repositories/centurylink/panamax-ui/tags"
PMX_API_TAGS="https://index.docker.io/v1/repositories/centurylink/panamax-api/tags"
SETUP_UPDATE_URL="http://download.panamax.io/installer/.versions"
DOCUMENTATION_URL="https://github.com/CenturyLinkLabs/panamax-ui/wiki/Release-Notes"
CWD="${HOME}/.panamax/"
PMX_VAR="${HOME}/.panamax"
ENV="$CWD".env_tmp
ENV_COMMIT="$PMX_VAR"/.env
IMAGES_VDI="$PMX_VAR"/images.vdi
IMAGES_ZIP="$PMX_VAR"/images.tar.gz
IMAGES_CDN="http://download.panamax.io/images.tar.gz"
PMX_VM_NAME="panamax-vm"
PMX_VM_MEMORY_DEFAULT=1536
PMX_VM_CPUS_DEFAULT=2
PMX_VM_PRIVATE_IP="10.0.0.200"
PMX_LOCAL_DOMAIN="panamax.local"
PMX_INSECURE_REGISTRY="n"
echo_install="init: First time installing Panamax! - Downloads CoreOS VM and installs latest Panamax version."
echo_restart="restart: Stops and Starts Panamax."
echo_reinstall="reinstall: Deletes your applications and CoreOS VM; reinstalls to latest Panamax version."
echo_update="download: Updates to latest Panamax version."
echo_checkUpdate="check: Checks for available updates for Panamax."
echo_info="info: Displays version of your local panamax install."
echo_stop="pause: Stops Panamax"
echo_start="up: Starts Panamax"
echo_uninstall="delete: Uninstalls Panamax, deletes applications and CoreOS VM."
echo_ssh="ssh: SSH into Panamax CoreOS VM."
echo_help="help: Show this help"
echo_debug="debug: Display your current Panamax settings."
function displayLogo {
tput clear
echo ""
echo -e "\033[0;31;32m███████╗ ██████╗ █████████╗ ██████╗ \033[0m\033[31;37m ██████████╗ ██████╗ ██╗ ██╗\033[0m"
echo -e "\033[0;31;32m██╔══██║ ╚═══██╗ ███╗ ███║ ╚═══██╗\033[0m\033[31;37m ██║ ██╔ ██║ ╚═══██╗ ╚██╗██╔╝\033[0m"
echo -e "\033[0;31;32m██ ██║ ███████║ ███║ ███║ ███████║\033[0m\033[31;37m ██║╚██║ ██║ ███████║ ╚███╔╝ \033[0m"
echo -e "\033[0;31;32m███████╝ ███████║ ███║ ███║ ███████║\033[0m\033[31;37m ██║╚██║ ██║ ███████║ ██╔██╗ \033[0m"
echo -e "\033[0;31;32m██║ ███████║ ███║ ███║ ███████║\033[0m\033[31;37m ██║╚██║ ██║ ███████║ ██╔╝ ██╗\033[0m"
echo -e "\033[0;31;32m╚═╝ ╚══════╝ ╚══╝ ╚══╝ ╚══════╝\033[0m\033[31;37m ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝\033[0m"
echo ""
echo "CenturyLink Labs - http://www.centurylinklabs.com/"
}
function checkPreReqs {
echo ""
echo "Checking if required software is installed."
echo ""
vagrant -v | grep -w '1.[6-9]' 2>&1 >/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Please install vagrant version 1.6.3 or newer (https://www.vagrantup.com/downloads.html).";
exit 1;
else
echo $'Vagrant 1.6 or newer installed.'
fi
VBoxManage -v | grep -w '4\.[3-]\|5\.[0-9]' 2>&1 >/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Please install Virtualbox 4.3 or newer (https://www.virtualbox.org/wiki/Downloads).";
exit 1;
else
echo $'Virtualbox 4.3 or newer installed.'
fi
echo ""
}
function checkPanamaxVmExists {
VBoxManage showvminfo $PMX_VM_NAME > /dev/null 2>&1
if [[ "$?" -ne "0" ]]; then
echo "The $PMX_VM_NAME does not exist. Please run ($ panamax init) to install Panamax."
echo ""
exit 1;
fi
}
function getLatestVersion () {
vList="$@"
versions=($@)
vMax=${versions[0]}
for i in "${versions[@]}"
do
result="`newerVersionAvailable $i \"$vList\"`"
if [[ "$result" == "0" ]]; then
vMax=$i
fi
done
echo $vMax
}
function newerVersionAvailable() {
local v1=$1
local vList=$2
majVer=`echo $v1 | awk -F "." '{ print $1 }'`
minVer=`echo $v1 | awk -F "." '{ print $2 }'`
patVer=`echo $v1 | awk -F "." '{ print $3 }'`
nextMinVer=`echo $minVer + 1 | bc`
nextMajVer=`echo $majVer + 1 | bc`
nextPatVer=`echo $patVer + 1 | bc`
local newVerAvailable=0
if [[ "`echo $vList | grep "$majVer.$minVer.$nextPatVer"`" != "" \
|| "`echo $vList | grep "$majVer.$nextMinVer.[0-9]\+"`" != "" \
|| "`echo $vList | grep "$nextMajVer\.[0-9]+\.[0-9]+"`" != "" ]]; then
newVerAvailable=1
fi
echo $newVerAvailable
}
function checkForSetupUpdate {
if [[ "$checkedSetupForUpdates" != "1" || "$1" == "u" ]]; then
checkedSetupForUpdates="1"
updateAvailableForSetup="0"
if [[ -f "$ENV" ]]; then
source "$ENV"
versionList=`curl -sL $SETUP_UPDATE_URL | grep tar`
local newVersionAvailable="`newerVersionAvailable $PMX_SETUP_VERSION \"$versionList\"`"
if [[ "$newVersionAvailable" == "1" ]]; then
echo "Local Panamax Installer version:"
echo "$PMX_SETUP_VERSION"
echo ""
echo "*** Panamax Installer is out of date! Please run ($ brew upgrade http://download.panamax.io/installer/brew/panamax.rb && panamax reinstall) to update. ***"
updateAvailableForSetup="1"
elif [[ "$1" == "e" ]]; then
echo "Local Panamax Installer version:"
echo " $PMX_SETUP_VERSION"
echo ""
fi
else
echo ""
fi
fi
}
function checkForPanamaxUpdate {
if [[ "$checkedPmxForUpdates" != "1" || "$1" == "u" ]]; then
checkedPmxForUpdates="1"
updateAvailableForPmx="0"
if [[ -f "$ENV" ]]; then
source "$ENV"
if [[ "$PMX_IMAGE_TAG" == "dev" ]]; then
if [[ "$PMX_INSTALL_DATE" -le "` date -j -v-1d +%s`" ]]; then
echo "You are currently running a Dev version of Panamax which is updated nightly."
echo "A newer Dev version is available. Use the update option to get the latest Dev version."
updateAvailableForPmx="1"
elif [[ "$1" == "e" ]]; then
echo "Local Panamax component versions:"
echo " UI: dev nightly build"
echo " API: dev nightly build"
fi
elif [[ "$PMX_INSTALL_TAG_UI" != "" || "$PMX_INSTALL_TAG_API" != "" || "$1" == "e" ]]; then
latestTagUi="`getLatestVersion $PMX_INSTALL_TAG_UI \"$(getTagsUi)\"`"
latestTagApi="`getLatestVersion $PMX_INSTALL_TAG_API \"$(getTagsApi)\"`"
if [[ "$PMX_INSTALL_TAG_UI" != "$latestTagUi" || "$PMX_INSTALL_TAG_API" != "$latestTagApi" ]]; then
echo "Local Panamax component versions:"
echo " UI: $PMX_INSTALL_TAG_UI"
echo " API: $PMX_INSTALL_TAG_API"
echo "Latest Panamax component versions:"
echo " UI: $latestTagUi"
echo " API: $latestTagApi"
echo ""
echo "*** Panamax is out of date! Please use the download/update option to get the latest. Release notes are available at ($DOCUMENTATION_URL) . ***"
echo ""
updateAvailableForPmx="1"
elif [[ "$1" == "e" ]]; then
echo "Local Panamax component versions:"
echo " UI: $PMX_INSTALL_TAG_UI"
echo " API: $PMX_INSTALL_TAG_API"
fi
fi
else
echo ""
fi
fi
}
function getPanamaxSetupVersion {
echo "\"$(<"$CWD.version")\""
exit 0;
}
function checkForUpdate {
if [[ "$1" == "e" || "$1" == "u" ]]; then
checkPreReqs
checkPanamaxVmExists
fi
echo ""
checkForPanamaxUpdate "$1"
checkForSetupUpdate "$1"
if [[ "$1" == "u" && $updateAvailableForSetup == "0" && $updateAvailableForPmx == "0" ]]; then
echo "Panamax is already up to date!"
fi
echo ""
}
function getTagsUi {
echo `curl --silent $PMX_UI_TAGS | grep -o "[0-9]*\.[0-9]*\.[0-9]*" | awk '{ print $1}'`
}
function getTagsApi {
echo `curl --silent $PMX_API_TAGS | grep -o "[0-9]*\.[0-9]*\.[0-9]*" | awk '{ print $1}'`
}
function runVagrant {
cd "$CWD" && vagrant "$@"
}
function saveVersionInfo {
setEnvVar "PMX_SETUP_VERSION" "\"$(<"$CWD.version")\""
setEnvVar "PMX_INSTALL_DATE" "\"`date +%s`\""
if [[ "$PMX_IMAGE_TAG" == "stable" ]]; then
setEnvVar "PMX_INSTALL_TAG_UI" "`getLatestVersion \"$(getTagsUi)\"`"
setEnvVar "PMX_INSTALL_TAG_API" "`getLatestVersion \"$(getTagsApi)\"`"
fi
setEnvVar "PMX_IMAGE_TAG" "$PMX_IMAGE_TAG"
}
function installPanamax {
checkPreReqs
echo "" > $ENV
setEnvVar "VAGRANT_DOTFILE_PATH" "$PMX_VAR"
source $ENV
if [[ "$operation" == "install" && "`runVagrant status $PMX_VM_NAME --machine-readable | grep "MachineNotFound\|not created"`" == "" ]]; then
echo "A different VM with name $PMX_VM_NAME has been created already. Please re-install or delete $PMX_VM_NAME VM and try again."
exit 1;
fi
if [[ "$operation" == "reinstall" ]]; then
checkPanamaxVmExists
fi
if [[ $# == 0 ]]; then
echo ""
read -p "Enter memory (MB) to be allocated to Panamax VM($PMX_VM_MEMORY_DEFAULT):" panamaxRam
read -p "Enter CPUs to be allocated to Panamax VM($PMX_VM_CPUS_DEFAULT):" panamaxCpus
read -p "Enter version you want to use(dev/stable, defaults to:$PMX_IMAGE_TAG_DEFAULT)" panamaxVersion
if [[ "`grep ${PMX_LOCAL_DOMAIN} /etc/hosts`" == "" ]]; then
read -p "Would you like Panamax to create the alias (${PMX_LOCAL_DOMAIN})? (You will be prompted for sudo creds) [y/N]:" localDomain
fi
read -p "Do you want to let Docker daemon allow connections to insecure registries [y/N]: " pmxInsecureRegistry
echo ""
fi
if [[ ("`grep ${PMX_LOCAL_DOMAIN} /etc/hosts`" == "") && ("${localDomain}" == "y" || "${localDomain}" == "Y") ]]; then
echo "Setting local alias to ${PMX_LOCAL_DOMAIN}"
if [[ "${sudoPassword}" == "" ]]; then
sudo -S -- sh -c "echo \"${PMX_VM_PRIVATE_IP} ${PMX_LOCAL_DOMAIN}\" >> /etc/hosts"
else
echo ${sudoPassword} | sudo -S -- sh -c "echo \"${PMX_VM_PRIVATE_IP} ${PMX_LOCAL_DOMAIN}\" >> /etc/hosts"
fi
fi
panamaxRam=${panamaxRam:-$PMX_VM_MEMORY_DEFAULT}
panamaxCpus=${panamaxCpus:-$PMX_VM_CPUS_DEFAULT}
redownload=${download:-N}
pmxInsecureRegistry=${pmxInsecureRegistry:-$PMX_INSECURE_REGISTRY}
PMX_IMAGE_TAG=${panamaxVersion:-${PMX_IMAGE_TAG:-$PMX_IMAGE_TAG_DEFAULT}}
if [ ! -d "$CWD" ]; then
mkdir -p "$CWD"
cp -Rf . "$CWD" > /dev/null
fi
if [[ "$PMX_BASEBOX" != "" && "$PMX_BASEBOX" != "$BASEBOX_DEFAULT" ]]; then
vagrant box remove $PMX_BASEBOX
fi
if [[ "$PMX_PANAMAX_ID" == "" ]]; then
PMX_PANAMAX_ID="`uuidgen`"
fi
setEnvVar "PMX_BASEBOX" \"$BASEBOX_DEFAULT\"
setEnvVar "PMX_BASEBOX_URL" \"$BASEBOX_URL_DEFAULT\"
setEnvVar "PMX_VM_MEMORY" $panamaxRam
setEnvVar "PMX_VM_CPUS" $panamaxCpus
setEnvVar "PMX_VM_PRIVATE_IP" \"${PMX_VM_PRIVATE_IP}\"
saveVersionInfo
setEnvVar "PMX_OPERATION" "$operation"
setEnvVar "PMX_VM_NAME" "$PMX_VM_NAME"
setEnvVar "PMX_PANAMAX_ID" \"${PMX_PANAMAX_ID}\"
setEnvVar "PMX_VAR_DIR" "$PMX_VAR"
setEnvVar "PMX_INSECURE_REGISTRY" "$pmxInsecureRegistry"
source "$ENV"
if [[ $operation == "reinstall" ]]; then
echo ""
echo "Reinstalling Panamax..."
if [[ "$#" == "0" ]]; then
read -p "Would you like to re-download coreos base box[y/N]: " redownload
fi
if [[ -f "$IMAGES_VDI" ]]; then
if [[ "`vboxmanage list runningvms | grep $PMX_VM_NAME`" != "" ]]; then
VBoxManage controlvm $PMX_VM_NAME poweroff
fi
VBoxManage storageattach $PMX_VM_NAME --storagectl "IDE Controller" --port 1 --device 0 --type hdd --medium 'none' > /dev/null 2>&1
VBoxManage closemedium disk $IMAGES_VDI > /dev/null 2>&1
VBoxManage internalcommands sethduuid $IMAGES_VDI
fi
VBoxManage unregistervm $PMX_VM_NAME --delete
if [[ $redownload == "Y" || $redownload == "y" ]]; then
vagrant box remove $PMX_BASEBOX
vagrant box add $PMX_BASEBOX $PMX_BASEBOX_URL
fi
updateCloudConfig
createPmxVM
else
updateCloudConfig
createPmxVM
fi
openPanamax;
}
function updateCloudConfig {
if [[ "`echo $PMX_INSECURE_REGISTRY | tr '[:upper:]' '[:lower:]'`" == "y" ]]; then
echo "#cloud-config
write_files:
- path: /etc/systemd/system/docker.service.d/50-insecure-registry.conf
content: |
[Service]
Environment=DOCKER_OPTS='--insecure-registry=\"0.0.0.0/0\"'" > $CWD/user-data
else
echo "#cloud-config
write_files:
- path: /etc/systemd/system/docker.service.d/50-insecure-registry.conf
content: |
[Service]
Environment=DOCKER_OPTS='--insecure-registry=\"10.10.10.254/24\"'" > $CWD/user-data
fi
if [[ -f "$PMX_VAR/cloud_config_usr.yaml" ]]; then
cat $PMX_VAR/cloud_config_usr.yaml >> $CWD/user-data
fi
}
function createPmxVM {
echo ""
echo "Creating a new CoreOS VM..."
if [[ ! -f "$IMAGES_VDI" ]]; then
if [[ -f "$IMAGES_ZIP" ]]; then
tar -zxf "$IMAGES_ZIP" -C "$PMX_VAR"
download_complete=$?
fi
if [[ "$download_complete" != "0" || ! -f "$IMAGES_ZIP" ]]; then
echo "Downloading images"
download_complete="-1"
until [ "$download_complete" == "0" ];
do
curl -C - $IMAGES_CDN -o "$IMAGES_ZIP" --progress-bar
sleep 2
tar -tzf "$IMAGES_ZIP" >/dev/null
download_complete=$?
done
fi
tar -zxf "$IMAGES_ZIP" -C "$PMX_VAR"
fi
if [[ ! -f "$IMAGES_VDI" ]]; then
echo "Error downloading images disk. Please try again later."
exit 1;
else
VBoxManage internalcommands sethduuid $IMAGES_VDI
fi
runVagrant up --provider virtualbox || { echo "VM Creation failed. Exiting."; exit 1; }
rm -f "$IMAGES_ZIP"
}
function setEnvVar {
local envVarName=`echo "$1" | sed 's/[PMX_]+//g'`
echo $"`sed "/$envVarName=/d" "$ENV"`" > "$ENV"
echo export $1=$2 >> "$ENV"
}
function openPanamax {
echo "waiting for panamax to start....."
local pmxUrl="http://${PMX_VM_PRIVATE_IP}:3000"
if [[ "`grep ${PMX_LOCAL_DOMAIN} /etc/hosts`" != "" ]]; then
pmxUrl="http://${PMX_LOCAL_DOMAIN}:3000"
fi
until [ `curl -sL -w "%{http_code}" "${pmxUrl}" -o /dev/null` == "200" ];
do
printf .
sleep 2
done
echo ""
open "${pmxUrl}" || { echo "Please go to ${pmxUrl}" to access panamax; }
echo "Please go to ${pmxUrl} to access panamax."
echo ""
echo ""
}
function savePortForwardingRules {
VBoxManage showvminfo $PMX_VM_NAME --machinereadable | grep 'Forwarding' | awk -F"=" '{print $2}' | sed 's/\"//g' | sed "s/^/VBoxManage controlvm $PMX_VM_NAME natpf1 \'/g" | sed "s/,/\',/" > "$CWD.portForwards.sh"
}
function recreatePortForwardingRules {
chmod +x "$CWD.portForwards.sh"
/bin/bash -c "cd $CWD && ./.portForwards.sh > /dev/null 2>&1" || true
}
function restartPanamax {
checkPreReqs
checkPanamaxVmExists
echo Restarting Panamax
setEnvVar "PMX_OPERATION" "$operation"
source "$ENV"
savePortForwardingRules
updateCloudConfig
runVagrant reload --provision || { echo >&2 "Restarting Panamax seems to have failed. Please try again using the reinstall option."; exit 1; }
recreatePortForwardingRules
echo $?
openPanamax;
echo Restart complete
}
function startPanamax {
checkPreReqs
checkPanamaxVmExists
echo Starting Panamax
setEnvVar "PMX_OPERATION" "$operation"
source "$ENV"
savePortForwardingRules
runVagrant up --provision || { echo >&2 "Starting Panamax seems to have failed. Please try again or use reinstall option."; exit 1; }
recreatePortForwardingRules
openPanamax
echo Start Complete
}
function stopPanamax {
checkPreReqs
checkPanamaxVmExists
echo Stopping Panamax
setEnvVar "PMX_OPERATION" "$operation"
source "$ENV"
runVagrant halt || { echo >&2 "Stopping Panamax seems to have failed. Please try again using the reinstall option."; exit 1; }
echo Panamax stopped.
}
function updatePanamax {
checkPreReqs
checkPanamaxVmExists
setEnvVar "PMX_OPERATION" "$operation"
setEnvVar "PMX_IMAGE_TAG" "$PMX_IMAGE_TAG"
source "$ENV"
checkForPanamaxUpdate
if [[ $updateAvailableForPmx == "1" ]]; then
echo Updating Panamax
savePortForwardingRules
runVagrant reload --provision || { echo >&2 "Updating Panamax seems to have failed. Please try again using the reinstall option."; exit 1; }
recreatePortForwardingRules
openPanamax;
saveVersionInfo
checkForSetupUpdate
echo Update Complete
else
echo "Panamax is already up to date."
fi
}
function uninstallPanamax {
checkPanamaxVmExists
setEnvVar "PMX_OPERATION" "$operation"
echo Uninstalling Panamax
runVagrant destroy -f
vagrant box remove $PMX_BASEBOX
echo Uninstall complete.
}
function sshToPanamax {
runVagrant ssh
}
function debug {
checkPanamaxVmExists
echo "Printing current env settings..."
sed 's/export //g' $ENV
}
function showShortHelp {
echo "panamax {init|up|pause|restart|info|check|download|reinstall|delete|help} [-ppUi=<panamax UI port>] [-ppApi=<panamax API port>] [--dev|stable] [-Id=y|n] [-sp=<sudo password>] [--memory=1536] [--cpu=2]"
echo ""
}
function showLongHelp {
showShortHelp
echo ""
echo $'\n' $'\n' "$echo_install" $'\n' "$echo_stop" $'\n' "$echo_start" $'\n' "$echo_restart" $'\n' "$echo_reinstall" $'\n' "$echo_info" $'\n' "$echo_checkUpdate" $'\n' "$echo_update" $'\n' "$echo_uninstall" $'\n' "$echo_ssh" $'\n' "$echo_help"
echo ""
}
function readParams {
for i in "$@"
do
case `echo $i | tr '[:upper:]' '[:lower:]'` in
--dev)
PMX_IMAGE_TAG=dev;;
--stable)
PMX_IMAGE_TAG=stable;;
--memory=*)
panamaxRam="${i#*=}";;
--cpu=*)
panamaxCpus="${i#*=}";;
install|init)
operation=install;;
uninstall|delete)
operation=uninstall;;
stop|pause)
operation=stop;;
start|up)
operation=start;;
restart)
operation=restart;;
update|download)
operation=update;;
check)
operation=check;;
info|--version|-v)
operation=info;;
reinstall)
operation=reinstall;;
ssh)
operation=ssh;;
debug)
operation=debug;;
-op=*|--operation=*)
operation="${i#*=}";;
-vd=*|--vagrantdownload=*)
download="${i#*=}";;
-ld=*|--localdomain=*)
localDomain="${i#*=}";;
-sp=*|--sudopassword=*)
sudoPassword="${i#*=}";;
--help|-h|help)
showLongHelp;
exit 1;;
-sv)
getPanamaxSetupVersion;;
--insecure-registry)
pmxInsecureRegistry="y";;
*)
showLongHelp;
exit 1;;
esac
done
}
function main {
if [[ -f "$ENV_COMMIT" ]]; then
cp "$ENV_COMMIT" "$ENV"
source "$ENV"
else
rm -f "$ENV"
touch "$ENV"
fi
if [[ ! -f "$PMX_VAR" ]]; then
mkdir -p "$PMX_VAR"
fi
if [[ "$1" != "-sv" ]]; then
displayLogo
fi
readParams "$@"
if [[ $# -gt 0 ]]; then
case $operation in
install) installPanamax "$@" || { showHelp; exit 1; } ;;
reinstall) installPanamax "$@" || { showHelp; exit 1; } ;;
restart) restartPanamax;;
stop) stopPanamax;;
start) startPanamax;;
check) checkForUpdate "u";;
info) checkForUpdate "e";;
update) updatePanamax;;
uninstall) uninstallPanamax;;
ssh) sshToPanamax;;
debug) debug;;
*) showLongHelp;;
esac
else
PS3="Please select one of the preceding options: "
select operation in "$echo_install" "$echo_stop" "$echo_start" "$echo_restart" "$echo_reinstall" "$echo_info" "$echo_checkUpdate" "$echo_update" "$echo_uninstall" "$echo_ssh" "$echo_help" "$echo_debug" "quit"; do
case $operation in
"$echo_install") operation="install"; installPanamax; break;;
"$echo_reinstall") operation="reinstall"; installPanamax; break;;
"$echo_restart") operation="restart"; restartPanamax; break;;
"$echo_start") operation="start"; startPanamax; break;;
"$echo_stop") operation="stop"; stopPanamax; break;;
"$echo_checkUpdate") operation="check"; checkForUpdate "u"; break;;
"$echo_info")operation="info"; checkForUpdate "e"; break;;
"$echo_update") operation="update"; updatePanamax; break;;
"$echo_uninstall") operation="uninstall"; uninstallPanamax; break;;
"$echo_help")showLongHelp; break;;
"$echo_ssh") sshToPanamax;;
"$echo_debug") debug; break;;
quit) exit 0;;
esac
done
fi
checkForUpdate
mv "$ENV" "$ENV_COMMIT"
exit 0;
}
main "$@";