#!/bin/bash # description: monitor-core build script # # Copyright 2008 GroundWork Open Source, Inc. (“GroundWork”) # All rights reserved. This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin # Street, Fifth Floor, Boston, MA 02110-1301, USA. # prefix=/usr/local/groundwork # Create groups and user ( nagios ) /usr/sbin/groupadd nagios >/dev/null 2>&1 & /usr/sbin/groupadd nagioscmd >/dev/null 2>&1 & if ! /usr/bin/id nagios &>/dev/null; then /usr/sbin/useradd -r -d $prefix/users/nagios -s /bin/bash -g "nagios" nagios || \ echo "Unexpected error adding user \"nagios\". Aborting installation." fi /usr/sbin/usermod -G nagios nagios &>/dev/null # Check for JAVA and make sure the it uses the JDK if [ -z $JAVA_HOME ] ; then /bin/echo "You don't have JAVA installed or the environment variable JAVA_HOME is not set correctly. Please install Java version version 1.5.x and set the JAVA_HOME environment variable in the root profile." exit 1 fi if [ ! -x "$JAVA_HOME"/bin/java -o ! -x "$JAVA_HOME"/bin/jdb -o ! -x "$JAVA_HOME"/bin/javac ]; then /bin/echo "The JAVA_HOME environment variable is not defined correctly. This environment variable is needed to run this program. NB: JAVA_HOME should point to a JDK not a JRE." exit 1 fi #Check JAVA VERSION, (we need 1.5 ) JAVA=$JAVA_HOME/bin/java $JAVA -version &> JAVA_VERSION /bin/cat JAVA_VERSION |grep 1.5 > JAVA_VERSION.1.5 file="JAVA_VERSION.1.5" if ! [ -s "$file" ] ; then /bin/echo "Please install Java version 1.5.x and and set the JAVA_HOME environment variable in the root profile." exit 1 fi /bin/echo "Current Java version: " $JAVA_HOME/bin/java -version # Check for javac compiler cat < Test.java class Test { public Test(){}} EOF javac -version Test.java if [ $? -eq 0 ] ; then echo "You have javac..." else echo "Please install javac compiler " fi rm Test.java rm Test.class # Check for gcc compiler gcc -v >/dev/null 2>&1 & if [ $? -eq 0 ] ; then echo "You have gcc..." else echo "Please install gcc compiler and gcc-devel package" fi # Check for g++ compiler g++ -v >/dev/null 2>&1 & if [ $? -eq 0 ] ; then echo "You have g++ compiler..." else echo "Please install g++ compiler" fi # Check MySQL database mysql -v >/dev/null 2>&1 & if [ $? -eq 0 ] ; then echo "You have MySQL database..." else echo "Please install MySQL database" fi # Check for ant build tools ant -v >/dev/null 2>&1 & if [ $? -eq 0 ] ; then echo "You have ant..." else echo "Please install ant build tools..." fi # Check for maven build tools maven -v >/dev/null 2>&1 & if [ $? -eq 0 ] ; then echo "You haven maven..." else echo "Please install maven-1.x build tools" fi # Check arch and if 64-bit set libdir to lib64 arch=$(arch) if [ -f ../monitor-core/project.properties ] ; then if [ "$arch" = "x86_64" ] ; then echo "libdir = lib64" >> ../monitor-core/project.properties echo "build = x86_64-redhat-linux-gnu" >> ../monitor-core/project.properties echo "host = x86_64-redhat-linux-gnu" >> ../monitor-core/project.properties echo "target = x86_64-redhat-linux-gnu" >> ../monitor-core/project.properties echo "compiler = linux-x86_64" >> ../monitor-core/project.properties elif [ "$arch" = "i686" ] ; then echo "libdir = lib" >> ../monitor-core/project.properties echo "build = i686-pc-linux-gnu" >> ../monitor-core/project.properties echo "host = i686-pc-linux-gnu" >> ../monitor-core/project.properties echo "target = i686-pc-linux-gnu" >> ../monitor-core/project.properties echo "compiler = linux-pentium" >> ../monitor-core/project.properties #elif [ $arch -eq ??? ] ; then # ADD YOUR SETTINGS HERE fi fi