| #!/bin/bash |
| # |
| # install.sh -- installs MySQL, Java, Tomcat, and the VMOps server |
| # |
| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| |
| #set -x |
| set -e |
| |
| EX_NOHOSTNAME=15 |
| EX_SELINUX=16 |
| |
| function usage() { |
| printf "Usage: %s [path to server-setup.xml]\n" $(basename $0) >&2 |
| exit 64 |
| } |
| |
| function checkhostname() { |
| if hostname | grep -qF . ; then true ; else |
| echo "You need to have a fully-qualified host name for the setup to work." > /dev/stderr |
| echo "Please use your operating system's network setup tools to set one." > /dev/stderr |
| exit $EX_NOHOSTNAME |
| fi |
| } |
| |
| function checkselinux() { |
| #### before checking arguments, make sure SELINUX is "permissible" in /etc/selinux/config |
| if /usr/sbin/getenforce | grep -qi enforcing ; then borked=1 ; fi |
| if grep -i SELINUX=enforcing /etc/selinux/config ; then borked=1 ; fi |
| if [ "$borked" == "1" ] ; then |
| echo "SELINUX is set to enforcing, please set it to permissive in /etc/selinux/config" > /dev/stderr |
| echo "then reboot the machine, after which you can run the install script again." > /dev/stderr |
| exit $EX_SELINUX |
| fi |
| } |
| |
| checkhostname |
| checkselinux |
| |
| if [ "$1" == "" ]; then |
| usage |
| fi |
| |
| if [ ! -f $1 ]; then |
| echo "Error: Unable to find $1" > /dev/stderr |
| exit 2 |
| fi |
| |
| #### check that all files exist |
| if [ ! -f apache-tomcat-6.0.18.tar.gz ]; then |
| printf "Error: Unable to find apache-tomcat-6.0.18.tar.gz\n" > /dev/stderr |
| exit 3 |
| fi |
| |
| if [ ! -f MySQL-client-5.1.30-0.glibc23.x86_64.rpm ]; then |
| printf "Error: Unable to find MySQL-client-5.1.30-0.glibc23.x86_64.rpm\n" > /dev/stderr |
| exit 4 |
| fi |
| |
| if [ ! -f MySQL-server-5.1.30-0.glibc23.x86_64.rpm ]; then |
| printf "Error: Unable to find MySQL-server-5.1.30-0.glibc23.x86_64.rpm\n" > /dev/stderr |
| exit 5 |
| fi |
| |
| if [ ! -f jdk-6u13-linux-amd64.rpm.bin ]; then |
| printf "Error: Unable to find jdk-6u13-linux-amd64.rpm.bin\n" > /dev/stderr |
| exit 6 |
| fi |
| |
| #if [ ! -f osol.tar.bz2 ]; then |
| # printf "Error: Unable to find osol.tar.bz2\n" |
| # exit 7 |
| #fi |
| |
| if [ ! -f apache-tomcat-6.0.18.tar.gz ]; then |
| printf "Error: Unable to find apache-tomcat-6.0.18.tar.gz\n" > /dev/stderr |
| exit 8 |
| fi |
| |
| if [ ! -f vmops-*.zip ]; then |
| printf "Error: Unable to find vmops install file\n" > /dev/stderr |
| exit 9 |
| fi |
| |
| if [ ! -f catalina ] ; then |
| printf "Error: Unable to find catalina initscript\n" > /dev/stderr |
| exit 10 |
| fi |
| |
| if [ ! -f usageserver ] ; then |
| printf "Error: Unable to find usageserver initscript\n" > /dev/stderr |
| exit 11 |
| fi |
| |
| ###### install Apache |
| # if [ ! -d /usr/local/tomcat ] ; then |
| echo "installing Apache..." |
| mkdir -p /usr/local/tomcat |
| tar xfz apache-tomcat-6.0.18.tar.gz -C /usr/local/tomcat |
| ln -s /usr/local/tomcat/apache-tomcat-6.0.18 /usr/local/tomcat/current |
| # fi |
| # if [ ! -f /etc/profile.d/catalinahome.sh ] ; then |
| # echo "export CATALINA_HOME=/usr/local/tomcat/current" >> /etc/profile.d/catalinahome.sh |
| # fi |
| source /etc/profile.d/catalinahome.sh |
| # if [ ! -f /etc/init.d/catalina ] ; then |
| cp -f catalina /etc/init.d |
| /sbin/chkconfig catalina on |
| # fi |
| |
| ####### set up usage server as a service |
| if [ ! -f /etc/init.d/usageserver ] ; then |
| cp -f usageserver /etc/init.d |
| /sbin/chkconfig usageserver on |
| fi |
| |
| ##### set up mysql |
| if rpm -q MySQL-server MySQL-client > /dev/null 2>&1 ; then true ; else |
| echo "installing MySQL..." |
| yum localinstall --nogpgcheck -y MySQL-*.rpm |
| fi |
| |
| #### install JDK |
| echo "installing JDK..." |
| sh jdk-6u13-linux-amd64.rpm.bin |
| rm -rf /usr/bin/java |
| ln -s /usr/java/default/bin/java /usr/bin/java |
| |
| #### setting up OSOL image |
| #mkdir -p $CATALINA_HOME/webapps/images |
| #echo "copying Open Solaris image, this may take a few moments..." |
| #cp osol.tar.bz2 $CATALINA_HOME/webapps/images |
| |
| #### deploying database |
| unzip -o vmops-*.zip |
| cd vmops-* |
| sh deploy-server.sh -d "$CATALINA_HOME" |
| cd db |
| sh deploy-db.sh "../../$1" templates.sql |
| |
| exit 0 |