This repository has been archived by the owner on Mar 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
/
bootstrap
executable file
·152 lines (130 loc) · 4.01 KB
/
bootstrap
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
#!/usr/bin/env bash
#
# File: bootstrap
# Description: This script configures Wirbelsturm for first use after a fresh checkout.
MYSELF=`basename $0`
MY_DIR=`echo $(cd $(dirname $0); pwd)`
. $MY_DIR/sh/common.sh
print_usage() {
echo "Usage: $MYSELF [--skip-ruby|-h]"
echo
echo " --skip-ruby Do not bootstrap Ruby/rvm/bundler/gems."
echo " -h, --help Print this help message and exit."
}
skip_ruby=0
while [[ $# -gt 0 ]]; do
case "$1" in
--skip-ruby)
skip_ruby=1
shift
;;
-h|--help)
print_usage
exit 98
;;
*)
error "Unexpected option ${1}"
echo
print_usage
exit 99
;;
esac
done
puts "+---------------------------+"
puts "| BOOTSTRAPPING WIRBELSTURM |"
puts "+---------------------------+"
###
### Ruby
###
if [ $skip_ruby -eq 1 ]; then
puts "Skipping prepration of Ruby environment. You must take care of this manually!"
else
puts -n "Checking for curl: "
which curl &>/dev/null
if [ $? -ne 0 ]; then
error "NOT FOUND"
warn "Please download and install curl and then re-run ${MYSELF}"
exit 1
else
success "OK"
fi
puts "Preparing Ruby environment..."
curl -L https://raw.githubusercontent.com/miguno/ruby-bootstrap/master/ruby-bootstrap.sh | bash -s
fi
# Ensure this terminal session knows about rvm
RVM_SCRIPT="$HOME/.rvm/scripts/rvm" # Note: Do not use `~`, stick with `$HOME`
[[ -s "$RVM_SCRIPT" ]] && source $RVM_SCRIPT
###
### Wirbelsturm
###
# Create a Wirbelsturm config if none exists yet
CONFIG_FILE=$MY_DIR/$WIRBELSTURM_CONFIG_FILE
CONFIG_FILE_TEMPLATE=$MY_DIR/$WIRBELSTURM_CONFIG_FILE_TEMPLATE
if [ ! -f $CONFIG_FILE ]; then
puts "Creating an example Wirbelsturm configuration file at $CONFIG_FILE..."
cp $CONFIG_FILE_TEMPLATE $CONFIG_FILE
# Restrict access to the config file as it may contain user credentials such as AWS secret keys.
chmod 600 $CONFIG_FILE
fi
###
### Vagrant
###
puts "Checking Vagrant environment..."
puts -n "Checking for Vagrant: "
which vagrant &>/dev/null
if [ $? -ne 0 ]; then
error "NOT FOUND"
warn "Please download and install Vagrant from http://downloads.vagrantup.com/ and then re-run ${MYSELF}"
exit 1
else
success "OK"
fi
puts "Preparing Vagrant environment..."
## Install required Vagrant plugins
# https://github.com/adrienthebo/vagrant-hosts
vagrant plugin install vagrant-hosts --plugin-version '>= 2.1.4'
# https://github.com/mitchellh/vagrant-aws
vagrant plugin install vagrant-aws
# https://github.com/johntdyer/vagrant-awsinfo
vagrant plugin install vagrant-awsinfo
# Install Vagrant boxes for the providers we use
vagrant box add --provider virtualbox centos6-compatible \
http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box
vagrant box add --provider aws centos6-compatible \
https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
###
### Puppet
###
puts "Checking Puppet environment..."
puts -n "Checking for librarian-puppet: "
which librarian-puppet &>/dev/null
if [ $? -ne 0 ]; then
error "NOT FOUND"
warn "Please run 'bundle install' and then re-run ${MYSELF}"
exit 2
else
success "OK"
fi
puts "Preparing Puppet environment..."
cd $MY_DIR/$PUPPET_DIR
librarian-puppet install
cd $MY_DIR
###
### Check for known problems that might cause trouble for our users
###
puts "Checking for known problems..."
VAGRANT_VERSION=`vagrant --version | awk '{ print $2 }'`
if [ "$VAGRANT_VERSION" = "1.3.5" ]; then
warn "Your Vagrant version has a known bug that causes problems with Wirbelsturm."
warn "We have already reported the bug including a fix to the Vagrant project."
warn "In the meantime please follow the instructions below to manually fix the bug:"
warn
warn " Go to: https://github.com/mitchellh/vagrant/issues/2493"
warn
warn "Once you have applied the fix please run the following command in the"
warn "top-level Wirbelsturm directory:"
warn
warn " $ vagrant plugin install vagrant-aws"
warn
warn "Sorry for any inconvenience!"
fi