Example Configure.sh Script
The following is an example of a configure.sh script.
#!/bin/sh
# Copyright (c) 2008 - 2016 TIBCO Software, Inc. All Rights Reserved.
# usage function
usage() {
echo "Usage: $0 -s server [-l {y|n}] [-P profiles_dir] [-t target_platform]"
echo
echo " -s name of the server, in [host]:[port] form"
echo " -l If y, then use SSL"
echo " -P name of the profiles directory, where configurartion information and daemon logs are stored. Default: ./profiles"
}
# register interrupted
interrupt() {
echo "Interrupted."
}
# trap to insure cleanup even if terminated
trap 'interrupt; exit' 2
# first order of business: explode the archives
failure() {
echo "$0: Error: The last operation failed"
echo "Aborting"
exit 1
}
if [ "z$DS_TARGET_PLATFORM" = "z" ]
then
DS_TARGET_PLATFORM=`uname -m`
fi
SYSTYPE=`uname -s`
CPUNAME=$DS_TARGET_PLATFORM
if [ "$SYSTYPE" = "Linux" ]; then
KERNELVER=`uname -r | head -c 5`
SYSTEM=linux
if [ "$CPUNAME" = "s390" ]; then
ARCH=s390
elif [ "$CPUNAME" = "ppc64" ]; then
ARCH=ppc64
elif [ "$CPUNAME" = "x86_64" ]; then
if [ "$KERNELVER" = "2.6.5" ]; then
LIBVER=amd64_SLES9
fi
ARCH=amd64
else
ARCH=i386
fi
UNZIP_TOOL=gunzip
HNAME=`hostname`
elif [ "$SYSTYPE" = "SunOS" ]; then
SYSTEM=solaris
if [ "$CPUNAME" = "i86pc" ]; then
if [ "z$SOLX86_32" != "z" ]; then
ARCH=i386
else
ARCH=amd64
fi
else
ARCH=sparc
fi
UNZIP_TOOL=gunzip
HNAME=`hostname | sed 's/\..*$//'`
elif [ "$SYSTYPE" = "HP-UX" ]; then
SYSTEM=hpux
if [ "$CPUNAME" = "ia64" ]; then
ARCH=hpux64
else
ARCH=hpux32
fi
UNZIP_TOOL=gunzip
HNAME=`hostname | sed 's/\..*$//'`
elif [ "$SYSTYPE" = "AIX" ]; then
SYSTEM=aix
ARCH=ppc
UNZIP_TOOL=gunzip
HNAME=`hostname | sed 's/\..*$//'`
ulimit -d unlimited
else
echo "SYSTYPE=$SYSTYPE"
echo "CPUNAME=$CPUNAME"
echo "This system is not supported."
exit 1
fi
# shell function for pulling properties file values
DATFILE=intranet.dat
parseProperty() {
propname=$1
if [ -z "$2" ]; then
propfile=$DATFILE
else
propfile=$2
fi
currprop=`sed -n -e "s/^$propname=\([^; ]*\).*\$/\1/p" $propfile`
}
# do not pull in existing environment variables
unset SERVER; unset PROFILESDIR; unset PROTOCOL
while getopts s:j:P:l: opt
do
case $opt in
s) SERVER=$OPTARG
;;
P) PROFILESDIR=$OPTARG
;;
l)
if [ $OPTARG = "y" ]; then
PROTOCOL="https";
else
PROTOCOL="http";
fi;
;;
\?) usage; exit
;;
esac
done
if [ -z "$SERVER" ]; then
usage
exit
fi
if [ -z "$PROTOCOL" ]; then
PROTOCOL="http";
fi
if [ -n "$LIBVER" ]; then
CURR=lib.$SYSTEM-$LIBVER
else
CURR=lib.$SYSTEM-$ARCH
fi
if [ ! -d lib ]; then
if [ ! -d $CURR ]; then
if [ ! -f $CURR.tar ]; then
if [ ! -f $CURR.tar.gz ]; then
echo "Fatal error: cannot find the archive $CURR.tar.gz"
exit 1
fi
echo "Unzipping $CURR.tar.gz"
${UNZIP_TOOL} $CURR.tar.gz
if [ $? -ne 0 ]; then failure; fi
fi
echo "Unpacking $CURR.tar"
tar -xf $CURR.tar
if [ $? -ne 0 ] ; then failure; fi
fi
echo "Renaming $CURR to lib"
mv $CURR lib
fi
if [ -z "$PROFILESDIR" ]; then PROFILESDIR=profiles; fi
if [ -f "$DATFILE" -a ! -z "$SERVER" ]; then
parseProperty server
OLDSERVER=$currprop
if [ "$OLDSERVER" != "$SERVER" ]; then
if [ -n "`find $PROFILESDIR/$HNAME -name "pid.*"`" ]; then
echo
echo "Error: you cannot specify a new server while"
echo "Engines are running from this install image."
echo "Please halt these Engines before continuing. Aborting..."
echo
exit 1;
fi
fi
fi
# review the config parameters and error check
while [ ! -d "$PROFILESDIR" -o ! -f "$TOUCHFILE" ]
do
MKCMD="mkdir -p $PROFILESDIR"
TOUCHFILE="$PROFILESDIR/.touchfile"
TOUCHCMD="touch $TOUCHFILE"
if [ ! -d "$PROFILESDIR" ] ; then
if $MKCMD 2>/dev/null ; then printf "" ; else
echo "Error: cannot create specified profiles dir $PROFILESDIR"
printf "Please specify a new directory: "
read PROFILESDIR
fi
elif [ ! -f "$TOUCHFILE" ]; then
if $TOUCHCMD 2>/dev/null ; then printf "" ; else
echo "Error: cannot write to specified profiles dir $PROFILESDIR"
printf "please specify a new directory: "
read PROFILESDIR
fi
fi
done
rm -f $TOUCHFILE
CURR=jre.$SYSTEM-$ARCH
if [ ! -d jre ]; then
if [ ! -d $CURR ]; then
if [ ! -f $CURR.tar ]; then
if [ ! -f $CURR.tar.gz ]; then
if [ "a$SYSTYPE" = "aAIX" ]; then
LIBPATH="./lib:$LIBPATH"
export LIBPATH
else
LD_LIBRARY_PATH="./lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
fi
hname=$HNAME
export hname
echo "Downloading $CURR.tar.gz from server"
./bin/installer doUrlToFile "$PROTOCOL://$SERVER/livecluster/public_html/register/install/jre/$CURR.tar.gz" $CURR.tar.gz
if [ $? -ne 0 ]; then
echo "Error: unable to download $CURR.tar.gz from server"
exit 1
fi
fi
echo "Unzipping $CURR.tar.gz"
${UNZIP_TOOL} $CURR.tar.gz
if [ $? -ne 0 ]; then failure; fi
fi
echo "Unpacking $CURR.tar"
tar -xf $CURR.tar
if [ $? -ne 0 ] ; then failure; fi
fi
echo "Renaming $CURR to jre"
mv $CURR jre
fi
echo
echo "Configuration parameters:"
echo "-------------------------"
printf "Controlling server:\t$SERVER\n"
printf "Controlling protocol:\t$PROTOCOL\n"
printf "Profiles directory:\t$PROFILESDIR\n"
echo
if [ -f "$DATFILE" ]; then
parseProperty server
OLDSERVER=$currprop
if [ "$OLDSERVER" != "$SERVER" ]; then
rm -f $PROFILESDIR/$HNAME/x4088*
fi
parseProperty protocol
OLDPROTOCOL=$currprop
if [ "$OLDSERVER" != "$PROTOCOL" ]; then
rm -f $PROFILESDIR/$HNAME/x4088*
fi
fi
echo "server=$SERVER" > $DATFILE
echo "protocol=$PROTOCOL" >> $DATFILE
echo "profilesdir=$PROFILESDIR" >> $DATFILE
echo "Done."
Copyright © Cloud Software Group, Inc. All rights reserved.
