#!/bin/sh #---------------------------------------------------------------------- # Copyright (c) 2015 Raytheon BBN Technologies # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and/or hardware specification (the "Work") to # deal in the Work without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Work, and to permit persons to whom the Work # 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 Work. # # THE WORK 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 WORK OR THE USE OR OTHER DEALINGS # IN THE WORK. #---------------------------------------------------------------------- # # UNCLASSIFIED // FOUO # #---------------------------------------------------------------------- # Script to set up a MongoDB install on CentOS, avoiding re-doing things # FIXME: Failing from install script # Go to a directory where we can download things user="`whoami`" if [ -e "/users/$user" ] then echo " ** Running as regular user $user" cd else echo " ** Running as install script user" cd /local fi # Bail if we've already run if [ -f "./installed.txt" ] then echo " ** Already installed" exit fi /usr/bin/sudo /bin/touch "./installed.txt" # Update centos # FIXME: Updates to CentOS2.6 - do we need to hold at 2.5? /bin/echo " ** Update CentOS...." /usr/bin/sudo /usr/bin/yum -y update & EPID=$! wait $EPID /usr/bin/yum -q grouplist installed "development tools" > /dev/null 2>&1 isinstalled=$? if [ $isinstalled -eq 1 ] then /usr/bin/sudo /usr/bin/yum groupinstall -y 'development tools' & EPID=$! wait $EPID fi /usr/bin/yum -q list installed wget > /dev/null 2>&1 isinstalled=$? if [ $isinstalled -eq 1 ] then /usr/bin/sudo /usr/bin/yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget & EPID=$! wait $EPID fi if [ ! -f "/usr/local/bin/python2.7" ] then # Build python /bin/echo "*****************************************" /bin/echo "Build Python...." /usr/bin/wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz & EPID=$! wait $EPID /usr/bin/xz -d Python-2.7.8.tar.xz & EPID=$! wait $EPID /bin/tar -xvf Python-2.7.8.tar & EPID=$! wait $EPID cd Python-2.7.8 /usr/bin/sudo ./configure --prefix=/usr/local & EPID=$! wait $EPID /usr/bin/sudo /usr/bin/make && /usr/bin/sudo /usr/bin/make altinstall & EPID=$! wait $EPID else echo " ** Python2.7 already installed" fi export PATH="/usr/local/bin:$PATH" if [ ! -f "/usr/local/lib/python2.7/site-packages/setuptools.pth" ] then # setuptools /bin/echo "*****************************************" /bin/echo "setuptools...." /usr/bin/wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz & EPID=$! wait $EPID /bin/tar -xvf setuptools-1.4.2.tar.gz & EPID=$! wait $EPID cd setuptools-1.4.2 /usr/bin/sudo /usr/local/bin/python2.7 setup.py install & EPID=$! wait $EPID else echo " ** setuptools already installed" fi if [ ! -f "/usr/local/bin/pip" ] then # pip /bin/echo "*****************************************" /bin/echo "Install pip" /usr/bin/sudo /usr/local/bin/python2.7 ez_setup.py & EPID=$! wait $EPID /usr/bin/sudo /usr/local/bin/python2.7 easy_install.py pip & EPID=$! wait $EPID # Some extras so we can use pyopenssl since this is python 2.7.8 that misses some SSL fixes /usr/bin/sudo /usr/bin/yum install -y libffi-devel & EPID=$! wait $EPID /usr/bin/sudo /usr/local/bin/pip2.7 install pyopenssl ndg-httpsclient pyasn1 & EPID=$! wait $EPID else echo " ** pip already installed" fi if [ ! -f "/etc/yum.repos.d/mongodb-org-3.0.repo" ] then # Create the repo file for mongodb /bin/echo "*****************************************" /bin/echo "Repo config for mongodb" cd /tmp /bin/cat >./mongodb-org-3.0.repo <"bind_ip=127.0.0.1,10.10.9.1" /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 # Turn off journaling; disks are typically too small # "# nojournal=true" -> "nojournal=true" /usr/bin/sudo /bin/sed -i 's/^# nojournal=true/nojournal=true/' /etc/mongod.conf else echo " ** MongoDB already installed" fi stat=`/usr/bin/sudo /sbin/service mongod status` wcr=`/bin/echo $stat | /bin/grep running | /usr/bin/wc -l` if [ $wcr -eq 0 ] then # Start mongo /bin/echo "*****************************************" /bin/echo "Start mongod" /usr/bin/sudo /sbin/service mongod start else /bin/echo " ** mongod already running" fi /bin/echo "Done configuring manager / DB node!"