1 | #!/bin/sh |
---|
2 | #---------------------------------------------------------------------- |
---|
3 | # Copyright (c) 2015 Raytheon BBN Technologies |
---|
4 | # |
---|
5 | # Permission is hereby granted, free of charge, to any person obtaining |
---|
6 | # a copy of this software and/or hardware specification (the "Work") to |
---|
7 | # deal in the Work without restriction, including without limitation the |
---|
8 | # rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
9 | # and/or sell copies of the Work, and to permit persons to whom the Work |
---|
10 | # is furnished to do so, subject to the following conditions: |
---|
11 | # |
---|
12 | # The above copyright notice and this permission notice shall be |
---|
13 | # included in all copies or substantial portions of the Work. |
---|
14 | # |
---|
15 | # THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
---|
16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
---|
19 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
---|
20 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
21 | # OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS |
---|
22 | # IN THE WORK. |
---|
23 | #---------------------------------------------------------------------- |
---|
24 | # |
---|
25 | # UNCLASSIFIED // FOUO |
---|
26 | # |
---|
27 | #---------------------------------------------------------------------- |
---|
28 | |
---|
29 | # Script to set up a MongoDB install on CentOS, avoiding re-doing things |
---|
30 | |
---|
31 | # FIXME: Failing from install script |
---|
32 | |
---|
33 | # Go to a directory where we can download things |
---|
34 | user="`whoami`" |
---|
35 | if [ -e "/users/$user" ] |
---|
36 | then |
---|
37 | echo " ** Running as regular user $user" |
---|
38 | cd |
---|
39 | else |
---|
40 | echo " ** Running as install script user" |
---|
41 | cd /local |
---|
42 | fi |
---|
43 | |
---|
44 | # Bail if we've already run |
---|
45 | if [ -f "./installed.txt" ] |
---|
46 | then |
---|
47 | echo " ** Already installed" |
---|
48 | exit |
---|
49 | fi |
---|
50 | |
---|
51 | /usr/bin/sudo /bin/touch "./installed.txt" |
---|
52 | |
---|
53 | # Update centos |
---|
54 | # FIXME: Updates to CentOS2.6 - do we need to hold at 2.5? |
---|
55 | /bin/echo " ** Update CentOS...." |
---|
56 | /usr/bin/sudo /usr/bin/yum -y update & EPID=$! |
---|
57 | wait $EPID |
---|
58 | |
---|
59 | /usr/bin/yum -q grouplist installed "development tools" > /dev/null 2>&1 |
---|
60 | isinstalled=$? |
---|
61 | if [ $isinstalled -eq 1 ] |
---|
62 | then |
---|
63 | /usr/bin/sudo /usr/bin/yum groupinstall -y 'development tools' & EPID=$! |
---|
64 | wait $EPID |
---|
65 | fi |
---|
66 | |
---|
67 | /usr/bin/yum -q list installed wget > /dev/null 2>&1 |
---|
68 | isinstalled=$? |
---|
69 | if [ $isinstalled -eq 1 ] |
---|
70 | then |
---|
71 | /usr/bin/sudo /usr/bin/yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget & EPID=$! |
---|
72 | wait $EPID |
---|
73 | fi |
---|
74 | |
---|
75 | if [ ! -f "/usr/local/bin/python2.7" ] |
---|
76 | then |
---|
77 | # Build python |
---|
78 | /bin/echo "*****************************************" |
---|
79 | /bin/echo "Build Python...." |
---|
80 | /usr/bin/wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz & EPID=$! |
---|
81 | wait $EPID |
---|
82 | /usr/bin/xz -d Python-2.7.8.tar.xz & EPID=$! |
---|
83 | wait $EPID |
---|
84 | /bin/tar -xvf Python-2.7.8.tar & EPID=$! |
---|
85 | wait $EPID |
---|
86 | cd Python-2.7.8 |
---|
87 | /usr/bin/sudo ./configure --prefix=/usr/local & EPID=$! |
---|
88 | wait $EPID |
---|
89 | /usr/bin/sudo /usr/bin/make && /usr/bin/sudo /usr/bin/make altinstall & EPID=$! |
---|
90 | wait $EPID |
---|
91 | else |
---|
92 | echo " ** Python2.7 already installed" |
---|
93 | fi |
---|
94 | export PATH="/usr/local/bin:$PATH" |
---|
95 | |
---|
96 | if [ ! -f "/usr/local/lib/python2.7/site-packages/setuptools.pth" ] |
---|
97 | then |
---|
98 | # setuptools |
---|
99 | /bin/echo "*****************************************" |
---|
100 | /bin/echo "setuptools...." |
---|
101 | /usr/bin/wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz & EPID=$! |
---|
102 | wait $EPID |
---|
103 | /bin/tar -xvf setuptools-1.4.2.tar.gz & EPID=$! |
---|
104 | wait $EPID |
---|
105 | cd setuptools-1.4.2 |
---|
106 | /usr/bin/sudo /usr/local/bin/python2.7 setup.py install & EPID=$! |
---|
107 | wait $EPID |
---|
108 | else |
---|
109 | echo " ** setuptools already installed" |
---|
110 | fi |
---|
111 | |
---|
112 | if [ ! -f "/usr/local/bin/pip" ] |
---|
113 | then |
---|
114 | # pip |
---|
115 | /bin/echo "*****************************************" |
---|
116 | /bin/echo "Install pip" |
---|
117 | /usr/bin/sudo /usr/local/bin/python2.7 ez_setup.py & EPID=$! |
---|
118 | wait $EPID |
---|
119 | /usr/bin/sudo /usr/local/bin/python2.7 easy_install.py pip & EPID=$! |
---|
120 | wait $EPID |
---|
121 | # Some extras so we can use pyopenssl since this is python 2.7.8 that misses some SSL fixes |
---|
122 | /usr/bin/sudo /usr/bin/yum install -y libffi-devel & EPID=$! |
---|
123 | wait $EPID |
---|
124 | /usr/bin/sudo /usr/local/bin/pip2.7 install pyopenssl ndg-httpsclient pyasn1 & EPID=$! |
---|
125 | wait $EPID |
---|
126 | else |
---|
127 | echo " ** pip already installed" |
---|
128 | fi |
---|
129 | |
---|
130 | if [ ! -f "/etc/yum.repos.d/mongodb-org-3.0.repo" ] |
---|
131 | then |
---|
132 | # Create the repo file for mongodb |
---|
133 | /bin/echo "*****************************************" |
---|
134 | /bin/echo "Repo config for mongodb" |
---|
135 | cd /tmp |
---|
136 | /bin/cat >./mongodb-org-3.0.repo <<EOF |
---|
137 | [mongodb-org-3.0] |
---|
138 | name=MongoDB Repository |
---|
139 | baseurl=https://repo.mongodb.org/yum/redhat/6/mongodb-org/3.0/x86_64/ |
---|
140 | gpgcheck=0 |
---|
141 | enabled=1 |
---|
142 | EOF |
---|
143 | /usr/bin/sudo /bin/chown root:root ./mongodb-org-3.0.repo |
---|
144 | /usr/bin/sudo /bin/mv ./mongodb-org-3.0.repo /etc/yum.repos.d/mongodb-org-3.0.repo |
---|
145 | else |
---|
146 | echo " ** MongoDB yum repo already installed" |
---|
147 | fi |
---|
148 | |
---|
149 | if [ ! -f "/usr/bin/mongod" ] |
---|
150 | then |
---|
151 | # Install mongo |
---|
152 | /bin/echo "*****************************************" |
---|
153 | /bin/echo "Install mongo" |
---|
154 | /usr/bin/sudo /usr/bin/yum install -y mongodb-org & EPID=$! |
---|
155 | wait $EPID |
---|
156 | |
---|
157 | # Ensure mongo can communicate: |
---|
158 | # For now, leave SELinux disabled so nothing to do here. |
---|
159 | # /bin/echo "*****************************************" |
---|
160 | # /bin/echo "SELinux config for mongo" |
---|
161 | # /usr/bin/sudo semanage port -a -t mongod_port_t -p tcp 27017 |
---|
162 | # /usr/bin/sudo semanage port -a -t mongod_port_t -p tcp 28017 |
---|
163 | |
---|
164 | # Edit the mongod.conf |
---|
165 | /bin/echo "*****************************************" |
---|
166 | /bin/echo "Configure MongoDB...." |
---|
167 | # Listen on the dataplane IP as well |
---|
168 | # "bind_ip=127.0.0.1"->"bind_ip=127.0.0.1,10.10.9.1" |
---|
169 | /usr/bin/sudo /bin/sed -i 's/^bind_ip=127.0.0.1/bind_ip=127.0.0.1,10.10.9.1/' /etc/mongod.conf |
---|
170 | |
---|
171 | # Turn off journaling; disks are typically too small |
---|
172 | # "# nojournal=true" -> "nojournal=true" |
---|
173 | /usr/bin/sudo /bin/sed -i 's/^# nojournal=true/nojournal=true/' /etc/mongod.conf |
---|
174 | else |
---|
175 | echo " ** MongoDB already installed" |
---|
176 | fi |
---|
177 | |
---|
178 | stat=`/usr/bin/sudo /sbin/service mongod status` |
---|
179 | wcr=`/bin/echo $stat | /bin/grep running | /usr/bin/wc -l` |
---|
180 | if [ $wcr -eq 0 ] |
---|
181 | then |
---|
182 | # Start mongo |
---|
183 | /bin/echo "*****************************************" |
---|
184 | /bin/echo "Start mongod" |
---|
185 | /usr/bin/sudo /sbin/service mongod start |
---|
186 | else |
---|
187 | /bin/echo " ** mongod already running" |
---|
188 | fi |
---|
189 | |
---|
190 | /bin/echo "Done configuring manager / DB node!" |
---|