./ctrl-setup.sh0000755000175000017500000001505512554231571014035 0ustar ahelsingahelsing#!/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 Ryu controller with a mongoDB client on CentOS, avoiding redoing things # Note that it only grabs the Ryu source if run directly by a user (not from a GENI install script) # 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 else echo " ** pip already installed" fi /usr/bin/yum -q list installed libxslt > /dev/null 2>&1 isinstalled=$? if [ $isinstalled -eq 1 ] then # Ryu dependencies /bin/echo "*****************************************" /bin/echo "Get Ryu dependencies" # First 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 # Then the things Ryu asked for /usr/bin/sudo /usr/bin/yum -y install libxml2-devel libxslt libxslt-devel & EPID=$! wait $EPID /usr/bin/sudo /usr/bin/yum -y install git & EPID=$! wait $EPID /usr/bin/sudo /usr/local/bin/pip2.7 install msgpack-python oslo.config netaddr lxml ecdsa & EPID=$! wait $EPID else echo " ** Ryu dependencies already installed" fi if [ ! -f "/usr/local/bin/ryu" ] then # Ryu /bin/echo "*****************************************" /bin/echo "Install Ryu" cd /usr/local/lib/python2.7/site-packages # FIXME: This package doesn't exist it appears if [ -f "/usr/local/lib/python2.7/site-packages/pbr-1.3.0.dist-info" ] then /usr/bin/sudo /bin/mv pbr-1.3.0.dist-info Test_pbr-1.3.0.dist-info fi # FIXME: Install of ryu decides it wants the latest pbr before 2.0 and gets 1.3.0, but something later wants <1.0 # So uninstall anything we have so far, install the specific version we want, and then the ryu install works /usr/bin/sudo /usr/local/bin/pip2.7 uninstall -y pbr & EPID=$! wait $EPID /usr/bin/sudo /usr/local/bin/pip2.7 install pbr==0.11.0 & EPID=$! wait $EPID /usr/bin/sudo /usr/local/bin/pip2.7 install ryu & EPID=$! wait $EPID else echo " ** Ryu already installed" fi if [ -e "/users/$user" ] then if [ ! -e "/users/$user/ryu" ] then # Ryu source /bin/echo "*****************************************" /bin/echo "Get Ryu source" cd /usr/bin/git clone git://github.com/osrg/ryu.git else /bin/echo " ** Ryu source already downloaded" fi else echo " ** Running as install script user, so not downloading ryu source." fi /usr/local/bin/python2.7 -c "import pymongo" > /dev/null 2>&1 isinstalled=$? if [ $isinstalled -eq 1 ] then # MongoDB client /bin/echo "*****************************************" /bin/echo "Install MongoDB pymongo client" /usr/bin/sudo /usr/local/bin/pip2.7 install pymongo & EPID=$! wait $EPID else /bin/echo " ** pymongo already installed" fi /bin/echo " ** Controller node setup with Ryu install done!"