Express Install

This is still very alpha. Please help improving these script. Related to Auto setup

Often when you develop stuff, or want to test for a bug in a specific version of EJBCA it would be nice to automate the process of setting up the environment and and preferably not mess up other installations on your machine.

(Sadly you still have to read (or press 'q') the JDK licence and type 'yes'. Simply unpacking the JDK-file with unzip will leave some .pack-files compressed.)

The following script

  • downloads all the components if necessary (except for the JCE Policy)
    • JDK 1.6 snapshot
    • JBoss with the Hypersonic database
    • Apache ant
    • EJBCA version or a CVS checkout of the latest version
  • installs them in the directory from where the script was run
    • includes Unlimited JCE Policy if available
    • can be customized with configuration in "./ejbca-custom/conf/"

Needed improvements:

  • download required files in parallel
  • better error handling
#
# The idea is to download and install EJBCA in one script
#

echo "Installing EJBCA without Unlimited JCE Policy files in `pwd`"
echo ""

EJBCA_VERSION="3_5_4"
#EJBCA_VERSION="head"
JBOSS_VERSION="4.2.2.GA"
ANT_VERSION="1.7.0"

if [ "`uname -a | grep x86_64`x" = "x" ] ; then
        JAVA_FILE="http://www.java.net/download/jdk6/6u10/promoted/b11/binaries/jdk-6u10-ea-bin-b11-linux-i586-24_jan_2008.bin"
else
        JAVA_FILE="http://www.java.net/download/jdk6/6u10/promoted/b11/binaries/jdk-6u10-ea-bin-b11-linux-amd64-24_jan_2008.bin"
fi

JCE_FILE="jce_policy-6.zip"
EJBCA_FILE="http://downloads.sourceforge.net/ejbca/ejbca_$EJBCA_VERSION.zip"
JBOSS_FILE="http://downloads.sourceforge.net/jboss/jboss-$JBOSS_VERSION.zip"
ANT_FILE="http://apache.dataphone.se/ant/binaries/apache-ant-$ANT_VERSION-bin.zip"

JAVA_DIR="jdk1.6.0_10"
EJBCA_DIR="ejbca_$EJBCA_VERSION"
JBOSS_DIR="jboss-$JBOSS_VERSION"
ANT_DIR="apache-ant-$ANT_VERSION"

CVS_CO_COMMAND="cvs -z3 -d:pserver:anonymous@ejbca.cvs.sourceforge.net:/cvsroot/ejbca co -d $EJBCA_DIR -P ejbca"
START_DIR="`pwd`"
export ANT_OPTS="-Xmx640m"

JCE_FILE_EXISTS="FALSE"

if [ -f $JCE_FILE ] ; then
    JCE_FILE_EXISTS="TRUE"
fi

unzip 1>/dev/null 2>/dev/null
if [ "$?" != "0" ] ; then
        echo "ERROR: This script requires unzip."
        echo ""
        exit 1
fi

# Download Java, JBoss and EJBCA
if [ ! -f "`basename $JAVA_FILE`" ] ; then
    wget $JAVA_FILE
else
    echo "`basename $JAVA_FILE` already exists. Skipping download."
fi

if [ ! -f "`basename $JBOSS_FILE`" ] ; then
        wget $JBOSS_FILE
else
        echo "`basename $JBOSS_FILE` already exists. Skipping download."
fi

if [ $EJBCA_VERSION = "head" ] ; then
    $CVS_CO_COMMAND
else
    if [ ! -f "`basename $EJBCA_FILE`" ] ; then
            wget $EJBCA_FILE
    else
            echo "`basename $EJBCA_FILE` already exists. Skipping download."
    fi
fi

if [ ! -f "`basename $ANT_FILE`" ] ; then
        wget $ANT_FILE
else
        echo "`basename $ANT_FILE` already exists. Skipping download."
fi

if [ ! -f "`basename $JAVA_FILE`" ] ; then
        echo "Could not download $JAVA_FILE!"
        exit 1
fi

if [ ! -f "`basename $JBOSS_FILE`" ] ; then
        echo "Could not download $JBOSS_FILE!"
        exit 1
fi

if [ $EJBCA_VERSION != "head" ] ; then
    if [ ! -f "`basename $EJBCA_FILE`" ] ; then
            echo "Could not download $EJBCA_FILE!"
            exit 1
    fi
fi

if [ ! -f "`basename $ANT_FILE`" ] ; then
        echo "Could not download $ANT_FILE!"
        exit 1
fi

rm -rf $JBOSS_DIR
unzip -o `basename $JBOSS_FILE`
rm -rf $JBOSS_DIR/server/all
rm -rf $JBOSS_DIR/server/minimal
if [ $EJBCA_VERSION != "head" ] ; then
    rm -rf $EJBCA_DIR
fi
unzip -o `basename $EJBCA_FILE`
rm -rf $ANT_DIR
unzip -o `basename $ANT_FILE`
rm -rf $JAVA_DIR
chmod +x `basename $JAVA_FILE`
./`basename $JAVA_FILE`

rm jboss
ln -s $JBOSS_DIR jboss
rm ejbca
ln -s $EJBCA_DIR ejbca
rm ant
ln -s $ANT_DIR ant
rm java
ln -s $JAVA_DIR java

export EJBCA_HOME="$START_DIR/ejbca"
export JAVA_HOME="$START_DIR/java"
export APPSRV_HOME="$START_DIR/jboss"
export JBOSS_HOME="$APPSRV_HOME"
export ANT_HOME="$START_DIR/ant"
export PATH="$JAVA_HOME/bin:$ANT_HOME/bin:$PATH"

if [ $JCE_FILE_EXISTS = "TRUE" ] ; then
    unzip -o $JCE_FILE
    mv -f jce/* $JAVA_HOME/jre/lib/security/
    rm -rf jce/
fi

cd $EJBCA_HOME
cp conf/ejbca.properties.sample conf/ejbca.properties
cp conf/web.properties.sample conf/web.properties
ant clean
ant bootstrap
rm $JBOSS_HOME/server/default/log/server.log
$JBOSS_HOME/bin/run.sh &
sleep 5
while [ "`grep Server.*JBoss.*Started $JBOSS_HOME/server/default/log/server.log 2>/dev/null`x" = "x" ] ; do echo -n "." ; sleep 2 ; done ; echo "." ;
ant install
$JBOSS_HOME/bin/shutdown.sh -S
while [ "`grep Server.*Shutdown.complete $JBOSS_HOME/server/default/log/server.log 2>/dev/null`x" = "x" ] ; do echo -n "." ; sleep 2 ; done ; echo "." ;
ant deploy
#ant clean

cd $START_DIR
echo ""
echo "All that is left now is.."
echo " - set your environment variables or edit /etc/environment"
echo "     export EJBCA_HOME=\"$EJBCA_HOME\""
echo "     export JBOSS_HOME=\"$JBOSS_HOME\""
echo "     export PATH=\"$JAVA_HOME/bin:$ANT_HOME/bin:$PATH\""
echo " - import $EJBCA_HOME/p12/superadmin.p12 in your browser"
if [ $JCE_FILE_EXISTS = "FALSE" ] ; then
        echo " - install Unlimited Strength Crypto Policy (or re-run this script with \"$JCE_FILE\" present) for full functionality"
fi
echo " - Re-run this script with predefined property-files in ./ejbca-custom/conf/ to customize the installation"
echo ""

To run this instance of EJBCA without altering the environment of your machine you can use the following script. It should be run from the same directory as the install script.

#
# Run JBoss with and spawn shell with correct environment
#

echo "Starting JBoss in background of new shell with correct environment.."

START_DIR="`pwd`"

export EJBCA_HOME="$START_DIR/ejbca"
export JAVA_HOME="$START_DIR/java"
export APPSRV_HOME="$START_DIR/jboss"
export JBOSS_HOME="$APPSRV_HOME"
export ANT_HOME="$START_DIR/ant"
export PATH="$JAVA_HOME/bin:$ANT_HOME/bin:$PATH"

cd $EJBCA_HOME

# Pick up changes in configuration and code
#export ANT_OPTS="-Xmx640m"
#ant clean; ant deploy
#if [ "$?" != "0" ] ; then
#        exit 1
#fi

rm $JBOSS_HOME/server/default/log/server.log
$JBOSS_HOME/bin/run.sh > /dev/null &
#$JBOSS_HOME/bin/run.sh &
sleep 5
while [ "`grep Server.*JBoss.*Started $JBOSS_HOME/server/default/log/server.log 2>/dev/null`x" = "x" ] ; do echo -n "." ; sleep 2; done ; echo "." ;
echo "JBoss running EJBCA was started."
bash
echo -n "Stopping JBoss."
$JBOSS_HOME/bin/shutdown.sh -S > /dev/null
while [ "`grep Server.*Shutdown.complete $JBOSS_HOME/server/default/log/server.log 2>/dev/null`x" = "x" ] ; do echo -n "." ; sleep 2; done ; echo "." ;

cd $START_DIR
echo "JBoss running EJBCA was stopped."
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License