blob: 10ba39d3dcdbdf8f084bf9777be4646ba1e211c9 (
plain)
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
|
#!/bin/bash
#
# This script will configure an Ubuntu server for use with RightScale
#
start() {
## First check to see if we were launched through RightScale. Exit and remove if not...
user_data=`curl -s -S -f -L --retry 7 -w ' %{http_code}' http://169.254.169.254/latest/user-data`
if `echo $user_data | grep -v "RS_token=" 1>/dev/null 2>&1` ; then
## Remove this init script so that it does not run again
remove
exit 0
fi
## ok, we were launched through RightScale, so let's continue
echo "Detected a RightScale instance..."
echo "Beginning configuration..."
## figure out which version of RightScale to install...
export rs_release=Ubuntu_`lsb_release -rs`
## Install some necessary packages
echo "Installing necessary packages..."
export DEBIAN_FRONTEND=NONINTERACTIVE
apt-get update
apt-get install -y binutils ruby1.8 sysv-rc-conf unzip ruby1.8-dev build-essential autoconf automake libtool logrotate rsync openssl ca-certificates libopenssl-ruby1.8
## Add rightscale customizations
echo "Installing RightScale"
curl -s -S -f -L --retry 7 -w ' %{http_code}' -o /tmp/rightscale_scripts.tgz http://s3.amazonaws.com/rightscale_scripts/rightscale_scripts_"$rs_release".tgz
tar -xzf /tmp/rightscale_scripts.tgz -C /opt/
ln -f /opt/rightscale/etc/init.d/rightscale /etc/init.d/rightscale
chmod +x /opt/rightscale/etc/init.d/rightscale
chmod +x /etc/init.d/rightscale
mkdir -p /etc/rightscale.d
update-rc.d rightscale start 98 2 3 4 5 . stop 1 0 1 6 .
ln -sf /usr/bin/ruby1.8 /usr/bin/ruby
ln -f /opt/rightscale/etc/motd /etc/motd
echo $rs_release > /etc/rightscale-release
## Add rubygems 1.8
echo "Installing RubyGems 1.8..."
curl -s -S -f -L --retry 7 -w ' %{http_code}' -o /tmp/rubygems.tgz http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
mkdir -p /tmp/rubygems
tar -xzvf /tmp/rubygems.tgz -C $root/tmp/rubygems
cd /tmp/rubygems/rubygems-1.3.1/
ruby setup.rb --no-rdoc --no-ri
ln -s /usr/bin/gem1.8 /usr/bin/gem
gem source -a http://ec2-us-east-mirror.rightscale.com/rubygems/archive/latest/
gem source -r http://mirror.rightscale.com
gem install --no-rdoc --no-ri xml-simple net-ssh net-sftp s3sync
updatedb
## Add some links to keep things inline
ln -s /usr/lib/site_ruby/aes /usr/local/lib/site_ruby/1.8/aes
ln -s /usr/lib/site_ruby/ec2 /usr/local/lib/site_ruby/1.8/ec2
ln -s /usr/bin/env /bin/env
## Insert 'ec2' as the cloud
echo "ec2" > /etc/rightscale.d/cloud
## Enable root logins
echo "Enabling root logins..."
cp -f /home/ubuntu/.ssh/authorized_keys /root/.ssh/.
## Remove the default sources.list becasue RightScale will create a better one anyways...
rm -f /etc/apt/sources.list.d/amazon.list
## Remove this init script so that it does not run again
remove
## Start the rightscale service
echo "Starting RightScale..."
/etc/init.d/rightscale start
echo "RightScale services started properly"
}
stop() {
exit 0
}
remove() {
my_name=`readlink -e $0`
update-rc.d -f `basename $my_name` remove
rm -f $my_name
}
# See how we were called.
case "$1" in
start)
start >>/var/log/install 2>&1
;;
stop)
stop >>/var/log/install 2>&1
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
esac
exit $?
|