Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

I've created a little linux bash-script that tries to auto-slim a JBoss server configuration.

Tested only with JBoss 4.2.3.GA and Seam 2.1.0.SP1.

How to use it: 1. Enter your jboss home dir in the script header 2. Run it and answer questions. 3. It will create a 'slim' configuration

Please adapt this script with more questions/features, but make sure you don't break standard Seam applications. Also, it would be nice to add security-related-slimming-questions.

Some references: JBoss 4 slimming JBoss security JBoss 3and4 slimming

(Sorry, this Knowledge Base doesn't seem to support attachments, putting the script inline)

#!/bin/sh

#
# Created by Bram Biesbrouck <b@beligum.org>
#
# Disclaimer: I was tired when I wrote this; you can't hold me responsible for it.
#
#
# Auto-slims a JBoss configuration, to turn a default config
# into a production config by asking a few questions.
# When you're uncertain, follow the hint.
#
# 
#

########################################
####FILL OUT THESE VARIABLES FIRST######
########################################

JBOSS_HOME=/home/bram/Programs/jboss-4.2.3.GA

########################################
########################################
########################################

if [ "${JBOSS_HOME}" == "" ]; then
    echo "Please adapt this script file with your own jboss-home-path"
    exit 1
fi
if [ ! -d "${JBOSS_HOME}" ]; then
    echo "You specified a jboss-home-path that doesn't exist, change this script's header first !"
    exit 1
fi

function processYNanswer()
{
    read answer

    if [ "$answer" == "y" ] || [ "$answer" == "Y" ] || [ "$answer" == "yes" ]; then
	return 1;
    fi

    if [ "$answer" == "n" ] || [ "$answer" == "N" ] || [ "$answer" == "no" ]; then
	return 0;
    fi

    echo "Unsupported answer (y/n), please try again:"
    processYNanswer
}

#echo -e -n "I'll make a backup of your original jboss_home to ${BACKUP_DIR} \nPress any key to continue... "
#read
#cp -r ${JBOSS_HOME} ${BACKUP_DIR}
#echo "done."


if [ -d "${JBOSS_HOME}/server/slim" ]; then
    echo "WARNING: a slim configuration exists, hit enter to continue, Ctrl-c to abort."
    read
fi

echo -n "Okay, let's get started with creating a 'slim' configuration... "

rm -rf "${JBOSS_HOME}/server/slim"
cp -r "${JBOSS_HOME}/server/default" "${JBOSS_HOME}/server/slim"
rm -rf "${JBOSS_HOME}/server/slim/work/*"
rm -rf "${JBOSS_HOME}/server/slim/log/*"
rm -rf "${JBOSS_HOME}/server/slim/tmp/*"
echo "done."


echo -e "\nYou want to remove web services (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -d "${JBOSS_HOME}/server/slim/deploy/jbossws.sar" ]; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/jbossws.sar"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove Quartz (hint:n)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -f "${JBOSS_HOME}/server/slim/deploy/quartz-ra.rar" ] && [ -f "${JBOSS_HOME}/server/slim/lib/quartz.jar" ]; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/quartz-ra.rar"
	rm -rf "${JBOSS_HOME}/server/slim/lib/quartz.jar"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove JBossMQ(JMS) (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -d "${JBOSS_HOME}/server/slim/deploy/jms" ] && [ -f "${JBOSS_HOME}/server/slim/lib/jbossmq.jar" ]; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/jms"
	rm -rf "${JBOSS_HOME}/server/slim/lib/jbossmq.jar"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove HTTPInvoker (which lets you tunnel RMI over HTTP) (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -d "${JBOSS_HOME}/server/slim/deploy/http-invoker.sar" ]; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/http-invoker.sar"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove BeanShell Deployer (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -f "${JBOSS_HOME}/server/slim/deploy/bsh-deployer.xml" ] && [ -f "${JBOSS_HOME}/server/slim/lib/bsh-deployer.jar" ] && [ -f "${JBOSS_HOME}/server/slim/lib/bsh.jar" ]; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/bsh-deployer.xml"
	rm -rf "${JBOSS_HOME}/server/slim/lib/bsh-deployer.jar"
	rm -rf "${JBOSS_HOME}/server/slim/lib/bsh.jar"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove Hypersonic (watch out if you use JMS !) (hint:n)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -f "${JBOSS_HOME}/server/slim/deploy/hsqldb-ds.xml" ] && [ -f "${JBOSS_HOME}/server/slim/lib/hsqldb-plugin.jar" ] && [ -f "${JBOSS_HOME}/server/slim/lib/hsqldb.jar" ]; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/hsqldb-ds.xml"
	rm -rf "${JBOSS_HOME}/server/slim/lib/hsqldb-plugin.jar"
	rm -rf "${JBOSS_HOME}/server/slim/lib/hsqldb.jar"
	echo "done."
    else
	echo "ERROR!"
    fi
fi


echo -e "\nYou want to remove the JMX-Console (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -d "${JBOSS_HOME}/server/slim/deploy/jmx-console.war" ]; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/jmx-console.war"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove both the management web-console and jsr-77 extensions (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -d "${JBOSS_HOME}/server/slim/deploy/management" ] ; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/management"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove the tomcat status pages (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -d "${JBOSS_HOME}/server/slim/deploy/jboss-web.deployer/ROOT.war" ] ; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/jboss-web.deployer/ROOT.war"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove the example scheduler-service.xml (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -f "${JBOSS_HOME}/server/slim/deploy/scheduler-service.xml" ] ; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/scheduler-service.xml"
	echo "done."
    else
	echo "ERROR!"
    fi
fi

echo -e "\nYou want to remove JBoss Scheduler Manager (allows you to schedule invocations against MBeans) (hint:y)?"
processYNanswer
if [ $? -eq 1 ]; then
    echo -n "Removing... "
    if [ -f "${JBOSS_HOME}/server/slim/deploy/schedule-manager-service.xml" ] && [ -f "${JBOSS_HOME}/server/slim/lib/scheduler-plugin.jar" ] && [ -f "${JBOSS_HOME}/server/slim/lib/scheduler-plugin-example.jar" ] ; then
	rm -rf "${JBOSS_HOME}/server/slim/deploy/schedule-manager-service.xml"
	rm -rf "${JBOSS_HOME}/server/slim/lib/scheduler-plugin.jar"
	rm -rf "${JBOSS_HOME}/server/slim/lib/scheduler-plugin-example.jar"
	echo "done."
    else
	echo "ERROR!"
    fi
fi
4 comments:
 
27. Jan 2009, 10:06 CET | Link

Great stuff Bram! Thank you very much for your work.

ReplyQuote
 
25. May 2009, 08:00 CET | Link

Something similar for jboss 5?

 

The human knowledge belongs to the world

 
12. Nov 2009, 16:10 CET | Link

I agree with Adrian, it would be great to have similar script for jboss5? I wanna try slim jboss5 on my vds instead of tomcat.

----------
My seam website

 
17. Feb 2010, 23:35 CET | Link
extremelyfatcat

Here is an ANT build file that attempts to create a slim server profile.

Based off of the following resources:


<?xml version="1.0"?>

<project name="Create a JBoss 5 AS Slim server profile" basedir="." default="help">

    <property name="jboss5.home.dir"            value="C:/jboss-5.1.0.GA" />  <!-- or wherever -->
    <property name="server.profile.dir"         value="${jboss5.home.dir}/server" />
    <property name="profile.src"                value="default" />
    <property name="default.profile.dest"       value="slim" />

    <target name="slim">
        <input message="Please enter the slim server profile name:"
               addproperty="profile.dest"
               defaultvalue="${default.profile.dest}" />


        <echo></echo>
        <echo>Creating new profile with settings:</echo>
        <echo></echo>
        <echo>jboss5.home.dir:     ${jboss5.home.dir}</echo>
        <echo>server.profile.dir:  ${server.profile.dir}</echo>
        <echo>profile.src:         ${profile.src}</echo>
        <echo>profile.dest:        ${profile.dest}</echo>
        <echo></echo>

        <echo>Deleting: ${server.profile.dir}/${profile.dest}</echo>
        <delete dir="${server.profile.dir}/${profile.dest}" />

        <mkdir dir="${server.profile.dir}/${profile.dest}" />

        <echo>Copying over the source profile .. </echo>
        <copy todir="${server.profile.dir}/${profile.dest}">
            <fileset dir="${server.profile.dir}/${profile.src}">
                <exclude name="work/**"/>
                <exclude name="log/**"/>
                <exclude name="tmp/**"/>
                <exclude name="data/**"/>

                <exclude name="deploy/http-invoker.sar/**" />              <!--  Removing HTTPInvoker (which lets you tunnel RMI over HTTP) -->
                <exclude name="deploy/management/**" />                    <!--  Removing Management web-console and jsr-77 extensions -->
                <exclude name="deploy/jbossws.sar/**" />                   <!--  Removing web services support -->
                <exclude name="deploy/scheduler-service.xml" />            <!--  Removing the scheduler service -->
                <exclude name="deploy/schedule-manager-service.xml" />     <!--  Removing the schedule manager service -->
                <!-- <exclude name="deploy/jmx-console.war/**" /> -->      <!--  Uncomment if not using the JMX console -->
                <exclude name="deploy/jmx-remoting.sar/**" />
                <exclude name="deploy/uuid-key-generator.sar/**" />
                <exclude name="deploy/messaging/**" />
                <exclude name="deploy/jms-ra.rar" />                       <!-- JCA resource adaptor that implements the JCA ManagedConnectionFactory interface for JMS connection factories -->
                <exclude name="deploy/cache-invalidation-service.xml" />   <!-- Required in case of clustered deployment -->

                <exclude name="deploy/mail-service.xml" />
                <exclude name="deploy/mail-ra.rar" />

                <exclude name="deploy/quartz-ra.rar" />

                <exclude name="deployers/bsh.deployer/**" />
                <exclude name="deployers/clustering-deployer-jboss-beans.xml" />  <!-- Needs to be restored if using clustered deployments -->
            </fileset>
        </copy>

        <!-- The defaultDS is used in other component, need more research before it can be removed -->
        <!-- <echo>Removing default hsql db datasource</echo> -->
        <!-- <delete file="${server.profile.dir}/${profile.dest}/deploy/hsqldb-ds.xml" /> -->


    </target>

    <!-- =================================================================== -->
    <!-- Prints a usage message                                              -->
    <!-- =================================================================== -->
    <target name="help" description="Prints this helpful usage message.">
        <echo></echo>
        <echo>Current settings:</echo>
        <echo>jboss5.home.dir:     ${jboss5.home.dir}</echo>
        <echo>server.profile.dir:  ${server.profile.dir}</echo>
        <echo>profile.src:         ${profile.src}</echo>
        <echo>profile.dest:        User entered value. Defaults to: ${default.profile.dest}</echo>
        <echo></echo>
        <echo>Ant targets:</echo>
        <echo></echo>
        <echo>slim    - This target creates the "slim" profile.</echo>
        <echo></echo>
    </target>

</project>

Post Comment