-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.dynamic.rebuild.all.local
151 lines (114 loc) · 4.2 KB
/
rc.dynamic.rebuild.all.local
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
#!/bin/bash
#
# A Script to build the base RightScale CentOS 5.4 Amazon Machine Image
# ami-f8b35e91 (32 bit)
# or
# ami-ccb35ea5 (64 bit)
# Into a mixed workload server for CommonMap purposes
# http://commonmap.info/w/index.php/Server/Setup/Demonstration/AWS
# Copyright Brendan Morley (morb_au), 2010
#
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# The general script actions are as follows:
#
# * Install common frameworks for each server role.
# * For each server role, install role-specifc components.
# * Update to the latest CentOS 5.4 patch level.
#
# The required server roles for this server are taken
# from the AWS user-data specified when this server was
# first deployed (i.e. from http://169.254.169.254/latest/user-data)
#
# Variables
DIR="$( cd "$( dirname "$0" )" && pwd )"
source $DIR/rc.dynamic.environment.inc.sh
echo "##############################################"
echo "#### Starting rc.dynamic.rebuild.all.local"
echo "##############################################"
date
# Get the User Data for this instance
userdata=`curl http://169.254.169.254/latest/user-data`
instanceid=`curl http://169.254.169.254/latest/meta-data/instance-id`
securitygroups=`curl http://169.254.169.254/latest/meta-data/security-groups`
manifest=`curl http://169.254.169.254/latest/meta-data/ami-manifest-path`
TIMESTAMP=`date -u +"%Y-%m-%d %H:%M:%S"`
## Tattoo these details on to the Message Of The Day
echo "This is a CommonMap server for the roles: '$userdata'." >> /etc/motd
echo "Built at $TIMESTAMP UTC, from:" >> /etc/motd
echo "$manifest" >> /etc/motd
echo "" >> /etc/motd
mail -s "[commonmap-bots] A $CM_ENV.commonmap.org is getting $userdata roles built" [email protected] < echo "Instance ID $instanceid"
echo "####"
echo "#### Calling rc.dynamic.rebuild.local"
echo "####"
date
/mnt/scripts/$CM_ENV/rc.dynamic.rebuild.local
for token in $userdata
do
case $token in
db-core)
echo "####"
echo "#### Calling rc.dynamic.rebuild.db-core.local"
echo "####"
date
/mnt/scripts/$CM_ENV/rc.dynamic.rebuild.db-core.local
;;
api)
echo "####"
echo "#### Calling rc.dynamic.rebuild.api.local"
echo "####"
date
/mnt/scripts/$CM_ENV/rc.dynamic.rebuild.api.local
;;
planet)
echo "####"
echo "#### Calling rc.dynamic.rebuild.planet.local"
echo "####"
date
/mnt/scripts/$CM_ENV/rc.dynamic.rebuild.planet.local
;;
db-tile)
echo "####"
echo "#### Calling rc.dynamic.rebuild.db-tile.local"
echo "####"
date
/mnt/scripts/$CM_ENV/rc.dynamic.rebuild.db-tile.local
;;
tile)
echo "####"
echo "#### Calling rc.dynamic.rebuild.tile.local"
echo "####"
date
/mnt/scripts/$CM_ENV/rc.dynamic.rebuild.tile.local
;;
esac
done
echo "####"
echo "#### Running yum update"
echo "####"
date
yum -y update
mail -s "[commonmap-bots] A $CM_ENV.commonmap.org has $userdata roles built" [email protected] < /mnt/instance/meta-data.log
echo "###############################################"
echo "#### Completed rc.dynamic.rebuild.all.local"
echo "###############################################"
date
# ENDS.