forked from spinnaker/spinnaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstallSpinnaker.sh
executable file
·784 lines (663 loc) · 24 KB
/
InstallSpinnaker.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
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
#!/bin/bash
# This script installs Spinnaker and its dependencies.
# See http://www.spinnaker.io/docs/creating-a-spinnaker-instance
set -e
set -o pipefail
REPOSITORY_URL="https://dl.bintray.com/spinnaker/debians"
# This script uses the following global variables.
AWS_ENABLED=false # set by --cloud_providers
AZURE_ENABLED=false # set by --cloud_providers
GOOGLE_ENABLED=false # set by --cloud_providers
INSTALL_CASSANDRA= # default depends on platform
# Set by --local-install, means download packages
# rather than adding additional external repositories.
DOWNLOAD=false
# Set by --quiet, wont prompt or echo status output.
QUIET=false
# Set by --dependencies only,
# Install dependencies but not spinnaker itself.
DEPENDENCIES_ONLY=false
# We can only currently support limited releases
# First guess what sort of operating system
# must have root perms
if [[ `/usr/bin/id -u` -ne 0 ]]; then
echo "$0 must be executed with root permissions; exiting"
exit 1
fi
if [[ -f /etc/lsb-release ]]; then
. /etc/lsb-release
DISTRO=$DISTRIB_ID
elif [[ -f /etc/debian_version ]]; then
DISTRO=Debian
# XXX or Ubuntu
elif [[ -f /etc/redhat-release ]]; then
if grep -iq cent /etc/redhat-release; then
DISTRO="CentOS"
elif grep -iq red /etc/redhat-release; then
DISTRO="RedHat"
fi
else
DISTRO=$(uname -s)
fi
# If not Ubuntu 14.xx.x or higher
if [[ "$DISTRO" == "Ubuntu" ]]; then
if [[ "${DISTRIB_RELEASE%%.*}" -lt 14 ]]; then
echo "Not a supported version of Ubuntu"
echo "Version is $DISTRIB_RELEASE we require 14.04 or higher"
exit 1
fi
else
echo "Not a supported operating system"
echo "Recommend you use Ubuntu 14.04 or higher"
exit 1
fi
function print_usage() {
cat <<EOF
usage: $0 [--cloud_provider <aws|google|azure|none>]
[--aws_region <region>] [--google_region <region>] [--azure_region <region>]
[--quiet] [--dependencies_only]
[--google_cloud_logging] [--google_cloud_monitoring]
[--repository <debian repository url>]
[--local-install] [--home_dir <path>]
If run with no arguments you will be prompted for cloud provider and region
--cloud_provider <arg> A space separated list of providers to enable.
Providers are "aws", "azure", and "google".
The default is "none".
--aws_region <arg> Default region for aws.
--google_region <arg> Default region for google.
--google_zone <arg> Default zone for google.
--azure_region <arg> Default region for Azure.
--quiet Sets cloud provider to "none". You will need to
edit /etc/default/spinnaker manually
cannot be used with --cloud_provider.
--repository <url> Obtain Spinnaker packages from the <url>
rather than the default repository, which is
$REPOSITORY_URL
--dependencies_only Do not install any Spinnaker services.
Only install the dependencies. This is intended
for development scenarios only.
--google_cloud_logging Install Google Cloud Logging support. This
is independent of installing on Google Cloud
Platform, but you may require additional
authorization. See https://cloud.google.com/logging/docs/agent/authorization#install_private-key_authorization
--google_cloud_monitoring Install Google Cloud Monitoring support. This
is independent of installing on Google Cloud
Platform, but you may require additional
authorization. See https://cloud.google.com/monitoring/api/authentication
--local-install For Spinnaker and Java packages, download
packages and install using dpkg instead of
apt. Use this option only if you are having
issues with the bintray repositories.
If you use this option you must manually
install openjdk-8-jdk.
--home_dir Override where user home directories reside
example: /export/home vs /home
--install_cassandra Force install of cassandra.
--noinstall_cassandra Do not install cassandra.
EOF
}
function echo_status() {
if ! $QUIET; then
echo "$@"
fi
}
function process_provider_list() {
local arr=($CLOUD_PROVIDER)
for provider in "${arr[@]}" ; do
case $provider in
aws)
echo "enabling aws provider"
AWS_ENABLED=true
;;
amazon)
echo "enabling aws provider"
AWS_ENABLED=true
;;
azure)
echo "enabling azure provider"
AZURE_ENABLED=true
;;
google)
echo "enabling google provider"
GOOGLE_ENABLED=true
;;
gce)
echo "enabling google provider"
GOOGLE_ENABLED=true
;;
both)
echo "WARNING: 'both' is deprecated. Use 'aws google' instead"
echo "enabling both aws and google provider"
GOOGLE_ENABLED=true
AWS_ENABLED=true
;;
none)
;;
*)
echo "Error invalid cloud provider: $CLOUD_PROVIDER"
echo "cannot continue installation; exiting."
exit 13
esac
done
}
function process_args() {
while [[ $# > 0 ]]
do
local key="$1"
shift
case $key in
--cloud_provider)
CLOUD_PROVIDER="$1"
process_provider_list
shift
;;
--aws_region)
AWS_REGION="$1"
shift
;;
--google_region)
GOOGLE_REGION="$1"
shift
;;
--azure_region)
AZURE_REGION="$1"
shift
;;
--google_zone)
GOOGLE_ZONE="$1"
shift
;;
--repository)
REPOSITORY_URL="$1"
shift
;;
--google_cloud_logging)
GOOGLE_CLOUD_LOGGING="true"
;;
--google_cloud_monitoring)
GOOGLE_CLOUD_MONITORING="true"
;;
--dependencies_only)
CLOUD_PROVIDER="none"
DEPENDENCIES_ONLY=true
;;
--local-install)
DOWNLOAD=true
;;
--install_cassandra)
INSTALL_CASSANDRA=true
;;
--noinstall_cassandra)
INSTALL_CASSANDRA=false
;;
--quiet|-q)
QUIET=true
CLOUD_PROVIDER="none"
AWS_REGION="none"
AZURE_REGION="none"
GOOGLE_REGION="none"
GOOGLE_ZONE="none"
;;
--home_dir)
homebase="$1"
if [[ "$(basename $homebase)" == "spinnaker" ]]; then
echo "stripping trailing 'spinnaker' from --home_dir=$homebase"
homebase=$(dirname $homebase)
fi
shift
;;
--help|-help|-h)
print_usage
exit 13
;;
*)
echo "ERROR: Unknown argument '$key'"
exit -1
esac
done
}
function prompt_if_unset() {
local name=$1
local default_value=$2
local prompt=$3
local tmp
if [[ "${!name}" == "" ]]; then
read -e -p "$prompt" tmp
eval ${name}=`echo ${tmp:=$default_value} | tr '[:upper:]' '[:lower:]'`
echo " set ${name}=\"${!name}\""
fi
}
function set_aws_region() {
if [[ "$AWS_REGION" == "" ]]; then
if [[ "$DEFAULT_AWS_REGION" == "" ]]; then
DEFAULT_AWS_REGION="us-west-2"
fi
prompt_if_unset AWS_REGION "$DEFAULT_AWS_REGION" "Specify default aws region: "
fi
}
function set_azure_region() {
if [[ "$AZURE_REGION" == "" ]]; then
if [[ "$DEFAULT_AZURE_REGION" == "" ]]; then
DEFAULT_AZURE_REGION="westus"
fi
prompt_if_unset AZURE_REGION "$DEFAULT_AZURE_REGION" "Specify default azure region (westus, centralus, eastus, eastus2): "
fi
}
function set_google_region() {
if [[ "$GOOGLE_REGION" == "" ]]; then
if [[ "$DEFAULT_GOOGLE_REGION" == "" ]]; then
DEFAULT_GOOGLE_REGION="us-central1"
fi
prompt_if_unset GOOGLE_REGION "$DEFAULT_GOOGLE_REGION" "Specify default google region: "
fi
}
function set_google_zone() {
if [[ "$GOOGLE_ZONE" == "" ]]; then
if [[ "$DEFAULT_GOOGLE_ZONE" == "" ]]; then
DEFAULT_GOOGLE_ZONE="us-central1-f"
fi
prompt_if_unset GOOGLE_ZONE "$DEFAULT_GOOGLE_ZONE" "Specify default google zone: "
fi
}
GOOGLE_METADATA_URL="http://metadata.google.internal/computeMetadata/v1"
function get_google_metadata_value() {
local path="$1"
local value=$(curl -L -s -f -H "Metadata-Flavor: Google" \
$GOOGLE_METADATA_URL/$path)
if [[ $? -eq 0 ]]; then
echo "$value"
else
echo ""
fi
}
AWS_METADATA_URL="http://169.254.169.254/latest/meta-data"
function get_aws_metadata_value() {
local path="$1"
local value=$(curl --connect-timeout 2 -s -f $AWS_METADATA_URL/$path)
if [[ $? -eq 0 ]]; then
echo "$value"
else
echo ""
fi
}
function write_default_value() {
local name="$1"
local value="$2"
if egrep "^$name=" /etc/default/spinnaker > /dev/null; then
sed -i.bak "s/^$name=.*/$name=$value/" /etc/default/spinnaker
else
bash -c "echo $name=$value >> /etc/default/spinnaker"
fi
}
function set_google_defaults_from_environ() {
local project_id=$(get_google_metadata_value "project/project-id")
local qualified_zone=$(get_google_metadata_value "instance/zone")
local zone=$(basename $qualified_zone)
local region=${zone%-*}
DEFAULT_CLOUD_PROVIDER="google"
GOOGLE_PROJECT_ID=$project_id
DEFAULT_GOOGLE_REGION="$region"
DEFAULT_GOOGLE_ZONE="$zone"
}
function set_aws_defaults_from_environ() {
local zone=$(get_aws_metadata_value "/placement/availability-zone")
local region=${zone%?}
local mac_addr=$(get_aws_metadata_value "/network/interfaces/macs/")
local vpc_id=$(get_aws_metadata_value "/network/interfaces/macs/${mac_addr}vpc-id")
local subnet_id=$(get_aws_metadata_value "/network/interfaces/macs/${mac_addr}subnet-id")
DEFAULT_CLOUD_PROVIDER="aws"
DEFAULT_AWS_REGION="$region"
AWS_VPC_ID="$vpc_id"
AWS_SUBNET_ID="$subnet_id"
}
function set_defaults_from_environ() {
local on_platform=""
local google_project_id=$(get_google_metadata_value "project/project-id")
if [[ -n "$google_project_id" ]]; then
on_platform="google"
set_google_defaults_from_environ
if [[ "$INSTALL_CASSANDRA" != "true" ]]; then
INSTALL_CASSANDRA=false
fi
fi
local aws_az=$(get_aws_metadata_value "/placement/availability-zone")
if [[ -n "$aws_az" ]]; then
on_platform="aws"
set_aws_defaults_from_environ
fi
if [[ "$on_platform" != "" ]]; then
echo "Determined that you are running on $on_platform infrastructure."
else
echo "No providers are enabled by default."
fi
}
function add_apt_repositories() {
# Redis
# https://launchpad.net/~chris-lea/+archive/ubuntu/redis-server
add-apt-repository -y ppa:chris-lea/redis-server
# Cassandra
# http://docs.datastax.com/en/cassandra/2.1/cassandra/install/installDeb_t.html
curl -s -L http://debian.datastax.com/debian/repo_key | apt-key add -
echo "deb http://debian.datastax.com/community/ stable main" | tee /etc/apt/sources.list.d/datastax.list > /dev/null
# Spinnaker
# DL Repo goes here
REPOSITORY_HOST=$(echo $REPOSITORY_URL | cut -d/ -f3)
if [[ "$REPOSITORY_HOST" == "dl.bintray.com" ]]; then
REPOSITORY_ORG=$(echo $REPOSITORY_URL | cut -d/ -f4)
# Personal repositories might not be signed, so conditionally check.
gpg=""
gpg=$(curl -s -f "https://bintray.com/user/downloadSubjectPublicKey?username=$REPOSITORY_ORG") || true
if [[ ! -z "$gpg" ]]; then
echo "$gpg" | apt-key add -
fi
fi
echo "deb $REPOSITORY_URL $DISTRIB_CODENAME spinnaker" | tee /etc/apt/sources.list.d/spinnaker-dev.list > /dev/null
# Java 8
# https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa
add-apt-repository -y ppa:openjdk-r/ppa
apt-get update ||:
}
function install_java() {
if ! $DOWNLOAD; then
apt-get install -y --force-yes openjdk-8-jdk
# https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/983302
# It seems a circular dependency was introduced on 2016-04-22 with an openjdk-8 release, where
# the JRE relies on the ca-certificates-java package, which itself relies on the JRE. D'oh!
# This causes the /etc/ssl/certs/java/cacerts file to never be generated, causing a startup
# failure in Clouddriver.
dpkg --purge --force-depends ca-certificates-java
apt-get install ca-certificates-java
elif [[ "x`java -version 2>&1|head -1`" != *"1.8.0"* ]]; then
echo "you must manually install java 8 and then rerun this script; exiting"
exit 13
fi
}
function install_platform_dependencies() {
local google_scopes=$(get_google_metadata_value "instance/service-accounts/default/scopes")
if [[ -z "$google_scopes" ]]; then
# Not on GCP
if [[ "$GOOGLE_CLOUD_LOGGING" == "true" ]] \
|| [[ "$GOOGLE_CLOUD_MONITORING" == "true" ]]; then
if [[ ! -f /etc/google/auth/application_default_credentials.json ]];
then
echo "You may need to add Google Project Credentials."
echo "See https://developers.google.com/identity/protocols/application-default-credentials"
fi
fi
fi
if [[ "$GOOGLE_CLOUD_LOGGING" == "true" ]]; then
# This can be installed on any platform, so dont scope to google.
# However, if on google, then certain scopes are required.
# The add_google_cloud_logging script checks the scope and warns.
curl -s -L https://raw.githubusercontent.com/spinnaker/spinnaker/master/google/google_cloud_logging/add_google_cloud_logging.sh | sudo bash
fi
if [[ "$GOOGLE_CLOUD_MONITORING" == "true" ]]; then
# This can be installed on any platform, so dont scope to google.
# However, if on google, then certain scopes are required.
curl -s https://repo.stackdriver.com/stack-install.sh | sudo bash
if [[ ! -z "$google_scopes" ]] && [[ $scopes != *"monitoring.write"* ]]; then
# This is not necessarily bad because we might be using this instance
# to create an image (e.g. packer). Only the runtime instances need
# this scope.
echo "Missing scope 'https://www.googleapis.com/auth/monitoring.write'"
echo "Google Cloud Monitoring will not be able to send data upstream."
fi
fi
}
function install_dependencies() {
# java
if ! $DOWNLOAD; then
apt-get install -y --force-yes unzip
else
mkdir $TEMPDIR/deppkgs && pushd $TEMPDIR/deppkgs
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/a/autogen/libopts25_5.18-2ubuntu2_amd64.deb
curl -L -O http://security.ubuntu.com/ubuntu/pool/main/n/ntp/ntp_4.2.6.p5+dfsg-3ubuntu2.14.04.5_amd64.deb
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/p/python-support/python-support_1.0.15_all.deb
curl -L -O http://security.ubuntu.com/ubuntu/pool/main/u/unzip/unzip_6.0-9ubuntu1.5_amd64.deb
dpkg -i *.deb
popd
rm -rf $TEMPDIR/deppkgs
fi
}
function install_redis_server() {
apt-get -q -y --force-yes install redis-server
local apt_status=$?
if [[ $apt_status -eq 0 ]]; then
return
fi
if $DOWNLOAD && [[ $apt_status -eq 100 ]]; then
echo "Manually downloading and installing redis-server..."
mkdir $TEMPDIR/deppkgs && pushd $TEMPDIR/deppkgs
curl -L -O http://mirrors.kernel.org/ubuntu/pool/universe/j/jemalloc/libjemalloc1_3.6.0-2_amd64.deb
curl -L -O https://launchpad.net/~chris-lea/+archive/ubuntu/redis-server/+build/8914180/+files/redis-server_3.0.7-1chl1~trusty1_amd64.deb
dpkg -i *.deb
popd
rm -rf $TEMPDIR/deppkgs
else
echo "Error installing redis-server."
echo "cannot continue installation; exiting."
exit 13
fi
}
function install_apache2() {
# If apache2 is installed, we want to do as little modification
# as possible to the existing installation.
if ! $(dpkg -s apache2 2>/dev/null >/dev/null)
then
echo "updating apt cache..." && apt-get -q update > /dev/null 2>&1 ||:
local apt_status=`apt-get -s -y --force-yes install apache2 > /dev/null 2>&1 ; echo $?`
if [[ $apt_status -eq 0 ]]; then
echo "apt sources contain apache2; installing using apt-get"
apt-get -q -y --force-yes install apache2
elif $DOWNLOAD && [[ $apt_status -eq 100 ]]; then
echo "no valid apache2 package found in apt sources; attempting to download debs and install locally..."
mkdir $TEMPDIR/apache2 && pushd $TEMPDIR/apache2
curl -L -O http://security.ubuntu.com/ubuntu/pool/main/a/apache2/apache2_2.4.7-1ubuntu4.5_amd64.deb
curl -L -O http://security.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-bin_2.4.7-1ubuntu4.5_amd64.deb
curl -L -O http://security.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-data_2.4.7-1ubuntu4.5_all.deb
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/a/apr/libapr1_1.5.0-1_amd64.deb
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/a/apr-util/libaprutil1_1.5.3-1_amd64.deb
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/a/apr-util/libaprutil1-dbd-sqlite3_1.5.3-1_amd64.deb
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/a/apr-util/libaprutil1-ldap_1.5.3-1_amd64.deb
curl -L -O http://mirrors.kernel.org/ubuntu/pool/main/s/ssl-cert/ssl-cert_1.0.33_all.deb
dpkg -i *.deb
popd && rm -rf $TEMPDIR/apache2
else
echo "unknown error ($apt_status) occurred attempting to install apache2"
echo "cannot continue installation; exiting"
exit 13
fi
# vhosts
if ! grep -Fxq "Listen 127.0.0.1:9000" /etc/apache2/ports.conf
then
sed -i "s/Listen\ 80/Listen 127.0.0.1:9000/" /etc/apache2/ports.conf
fi
else
# vhosts
if ! grep -Fxq "Listen 127.0.0.1:9000" /etc/apache2/ports.conf
then
echo "Listen 127.0.0.1:9000" >> /etc/apache2/ports.conf
fi
fi
}
function install_cassandra() {
# "service cassandra status" is currently broken in Ubuntu grep in the script is grepping for things that do not exist
# Cassandra 2.x can ship with RPC disabled to enable run "nodetool enablethrift"
local package_url="http://debian.datastax.com/community/pool"
if [[ "x`java -version 2>&1|head -1`" != *"1.8.0"* ]]; then
cat <<EOF
java 8 is not installed, cannot install cassandra
After installing java 8 run the following to install cassandra:
sudo apt-get install -y --force-yes cassandra=2.1.11 cassandra-tools=2.1.11
sudo apt-mark hold cassandra cassandra-tools
cannot continue installation; exiting
EOF
exit 13
fi
local cassandra_packages=$(apt-cache search cassandra)
if [[ -z "$cassandra_packages" ]]; then
if $DOWNLOAD; then
echo "cassandra not found in apt-cache, downloading from $package_url..."
mkdir $TEMPDIR/casspkgs && pushd $TEMPDIR/casspkgs
for pkg in cassandra cassandra-tools;do
curl -L -O $package_url/${pkg}_2.1.11_all.deb
done
dpkg -i *.deb
apt-mark hold cassandra cassandra-tools
popd
rm -rf $TEMPDIR/casspkgs
else
echo "Error installing cassandra."
echo "cannot continue installation; exiting."
exit 13
fi
else
apt-get install -y --force-yes cassandra=2.1.11 cassandra-tools=2.1.11
apt-mark hold cassandra cassandra-tools
sleep 1
fi
# Let cassandra start
if ! nc -z localhost 7199; then
echo_status "Waiting for Cassandra to start..."
count=0
while ! nc -z localhost 7199; do
sleep 1
count=`expr $count + 1`
if [[ $count -eq 30 ]]; then
break
fi
done
if ! nc -z localhost 7199; then
echo "Cassandra has failed to start; exiting"
exit 13
else
echo_status "Cassandra is ready."
fi
fi
while ! $(nodetool enablethrift >& /dev/null); do
sleep 1
echo_status "Retrying..."
done
}
function install_spinnaker() {
apt-get install -y --force-yes --allow-unauthenticated spinnaker
local apt_status=$?
if [[ $apt_status -ne 0 ]]; then
if $DOWNLOAD && [[ $apt_status -eq 100 ]]; then
install_packages="spinnaker-clouddriver spinnaker-deck spinnaker-echo spinnaker-fiat spinnaker-front50 spinnaker-gate spinnaker-igor spinnaker-orca spinnaker-rosco spinnaker_"
for package in $install_packages;do
latest=`curl $REPOSITORY_URL/dists/$DISTRIB_CODENAME/spinnaker/binary-amd64/Packages | grep "^Filename" | grep $package | awk '{print $2}' | awk -F'/' '{print $NF}' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1`
debfile=`echo $latest | awk -F "/" '{print $NF}'`
filelocation=`curl $REPOSITORY_URL/dists/$DISTRIB_CODENAME/spinnaker/binary-amd64/Packages | grep "^Filename" | grep $latest | awk '{print $2}'`
curl -L -o /tmp/$debfile $REPOSITORY_URL/$filelocation
dpkg -i /tmp/$debfile && rm -f /tmp/$debfile
done
else
echo "Error installing spinnaker."
echo "cannot continue installation; exiting."
exit 13
fi
fi
}
set_defaults_from_environ
process_args "$@"
prompt_if_unset CLOUD_PROVIDER "$DEFAULT_CLOUD_PROVIDER" "Specify a cloud provider (aws|azure|google|none): "
process_provider_list
#enable cloud provider specific settings
if $AWS_ENABLED; then
set_aws_region
fi
if $AZURE_ENABLED; then
set_azure_region
fi
if $GOOGLE_ENABLED; then
set_google_region
set_google_zone
fi
# Only add external apt repositories if we are not --local_install
if ! $DOWNLOAD; then
add_apt_repositories
fi
TEMPDIR=$(mktemp -d installspinnaker.XXXX)
install_java
install_apache2
install_platform_dependencies
install_dependencies
install_redis_server
if [[ "$INSTALL_CASSANDRA" != "false" ]]; then
install_cassandra
fi
## Packer
mkdir $TEMPDIR/packer && pushd $TEMPDIR/packer
curl -s -L -O https://releases.hashicorp.com/packer/0.12.1/packer_0.12.1_linux_amd64.zip
unzip -u -o -q packer_0.12.1_linux_amd64.zip -d /usr/bin
popd
rm -rf $TEMPDIR/packer
rm -rf $TEMPDIR
if $DEPENDENCIES_ONLY; then
exit 0
fi
## Spinnaker
install_spinnaker
if [[ "$INSTALL_CASSANDRA" != "false" ]]; then
# Touch a file to tell other scripts we installed Cassandra.
touch /opt/spinnaker/cassandra/SPINNAKER_INSTALLED_CASSANDRA
cqlsh -f "/opt/spinnaker/cassandra/create_echo_keyspace.cql"
cqlsh -f "/opt/spinnaker/cassandra/create_front50_keyspace.cql"
else
/opt/spinnaker/install/change_cassandra.sh --echo=inMemory --front50=gcs --change_defaults=true --change_local=false
fi
# Write values to /etc/default/spinnaker.
if [[ $AWS_ENABLED || $AZURE_ENABLED || $GOOGLE_ENABLED ]] ; then
if [[ $AWS_ENABLED == true ]] ; then
write_default_value "SPINNAKER_AWS_ENABLED" "true"
write_default_value "SPINNAKER_AWS_DEFAULT_REGION" $AWS_REGION
write_default_value "AWS_VPC_ID" $AWS_VPC_ID
write_default_value "AWS_SUBNET_ID" $AWS_SUBNET_ID
fi
if [[ $AZURE_ENABLED == true ]] ; then
write_default_value "SPINNAKER_AZURE_ENABLED" "true"
write_default_value "SPINNAKER_AZURE_DEFAULT_REGION" $AZURE_REGION
fi
if [[ $GOOGLE_ENABLED == true ]] ; then
write_default_value "SPINNAKER_GOOGLE_ENABLED" "true"
write_default_value "SPINNAKER_GOOGLE_PROJECT_ID" $GOOGLE_PROJECT_ID
write_default_value "SPINNAKER_GOOGLE_DEFAULT_REGION" $GOOGLE_REGION
write_default_value "SPINNAKER_GOOGLE_DEFAULT_ZONE" $GOOGLE_ZONE
fi
else
echo "Not enabling a cloud provider"
fi
## Remove
if [[ "$homebase" == "" ]]; then
homebase="/home"
echo "Setting spinnaker home to $homebase"
fi
if [[ -z `getent group spinnaker` ]]; then
groupadd spinnaker
fi
if [[ -z `getent passwd spinnaker` ]]; then
useradd --gid spinnaker -m --home-dir $homebase/spinnaker spinnaker
fi
if [[ ! -d $homebase/spinnaker ]]; then
mkdir -p $homebase/spinnaker/.aws
chown -R spinnaker:spinnaker $homebase/spinnaker
fi
##
start spinnaker
if ! $QUIET; then
cat <<EOF
To stop all spinnaker subsystems:
sudo stop spinnaker
To start all spinnaker subsystems:
sudo start spinnaker
To configure the available cloud providers:
Edit: /etc/default/spinnaker
And/Or: /opt/spinnaker/config/spinnaker-local.yml
Next, ensure that the regions configured in deck are up-to-date:
sudo /opt/spinnaker/bin/reconfigure_spinnaker.sh
Lastly, restart clouddriver and rosco with:
sudo service clouddriver restart
sudo service rosco restart
EOF
fi