-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
66 lines (53 loc) · 1.92 KB
/
bootstrap.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
#!/bin/bash
# Bootstrap
# By Jesse Collier <[email protected]>
# November 15th, 2013
# This script assumes the following
# - You are running ubuntu
# - Your base image includes a cronjob
# that downloads and executes this bootstrap
if [ ! -a /etc/cron.d/bootstrap ]; then
logger "[$$] [$0] exiting... already bootstrapped"
fi
logger "[$$] [$0] bootstrapping. Hang on..."
# Upgrade system to latest
logger "[$$] [$0] upgrade system"
apt-get update
apt-get upgrade -y
logger "[$$] [$0] upgrade system complete"
# Install ruby+chef
logger "[$$] [$0] install ruby+chef"
sudo apt-get install ruby1.9.1 ruby1.9.1-dev \
rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \
build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1
# choose your interpreter
# changes symlinks for /usr/bin/ruby , /usr/bin/gem
# /usr/bin/irb, /usr/bin/ri and man (1) ruby
sudo update-alternatives --config ruby
sudo update-alternatives --config gem
gem update --no-rdoc --no-ri
logger "[$$] [$0] ruby+chef installed"
# Set up berkshelf
logger "[$$] [$0] install bundler"
gem install bundler
logger "[$$] [$0] bundler installed"
# Install git
logger "[$$] [$0] install git"
apt-get install -y git
logger "[$$] [$0] git installed"
# Set up chef
logger "[$$] [$0] setting up chef"
mkdir /srv
cd /srv && git clone https://github.com/jessecollier/server-config.git
cd /srv/server-config && bundle install
cd /srv/server-config && berks install --path chef/cookbooks
chef-solo -c /srv/server-config/chef/config.rb
logger "[$$] [$0] chef complete"
logger "[$$] [$0] removing bootstrap"
rm /etc/cron.d/bootstrap