Tuesday, January 4, 2011

JBoss and Fedora/Centos startup script

After months of hacking away and then letting it fall off my plate then revisiting this again, I finally got a Jboss startup script to work.

I am using Jboss-4.2.3-GA installed into /usr/local/jboss/jboss-4.2.3.GA
I am using jdk-6u18-linux-i586.rpm for my java.

I copied the /usr/local/jboss/jboss-4.2.3.GA/bin/jboss_init_redhat.sh to /etc/init.d/jboss and made some modifications.

I added:
# chkconfig: 345 90 10
# description: Runs the JBoss Application Server
# processname: jboss

below the :
# JBoss Control Script
line.
I made the usual modifications to:
JBOSS_HOME
JAVAPTH
JBOSS_HOST

My changes were to:
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh $JBOSS_BIND_ADDR" }
# define jboss startlog
JBOSS_LOG=${JBOSS_LOG:-"$JBOSS_HOME/server/default/log/startJBossServer.log"}

and the major changes was:
JBOSS_CMD_START="cd $JBOSS_HOME/bin; nohup $JBOSSSH"
and
case "$1" in
start)
cd $JBOSS_HOME/bin
if [ -z "$SUBIT" ]; then
eval $JBOSS_CMD_START 2>&1 >>${JBOSS_LOG} &
else
$SUBIT "$JBOSS_CMD_START 2>&1 >> ${JBOSS_LOG} &"
fi
;;

What I noticed is that although chkconfig --list jboss would show jboss listed as on for run levels 3,4,5 - for some reason, jboss would start then shutdown on reboot.
It seemed as if it weren't handing off to daemon to start, so I added nohup.
Instead of redircting output to /dev/null aka JBOSS_CONSOLE, I wanted to redirect this to a start log which I created called JBOSS_LOG.

Here's the script in the entirety:
#!/bin/sh
#
# $Id: jboss_init_redhat.sh 71252 2008-03-25 17:52:00Z dbhole $
#
# JBoss Control Script
#
# To use this script run it as root - it will switch to the specified user
#
# Here is a little (and extremely primitive) startup/shutdown script
# for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.
# All this can be changed in the script itself.
#
# Either modify this script for your requirements or just ensure that
# the following variables are set correctly before calling the script.
#
# chkconfig: 345 90 10
# description: Runs the JBoss Application Server
# processname: jboss

#define where jboss is - this is the directory containing directories log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-"/usr/local/jboss/jboss-4.2.3.GA"}

#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
JBOSS_USER=${JBOSS_USER:-"jboss"}

# define jboss startlog
JBOSS_LOG=${JBOSS_LOG:-"$JBOSS_HOME/server/default/log/startJBossServer.log"}

#make sure java is in your path
JAVAPTH=${JAVAPTH:-"/usr/java/latest/bin"}

#configuration to use, usually one of 'minimal', 'default', 'all'
JBOSS_CONF=${JBOSS_CONF:-"default"}

#if JBOSS_HOST specified, use -b to bind jboss services to that address
JBOSS_HOST="0.0.0.0"
JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}

#define the script to use to start jboss
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh $JBOSS_BIND_ADDR" }

if [ "$JBOSS_USER" = "RUNASIS" ]; then
SUBIT=""
else
SUBIT="su - $JBOSS_USER -c "
fi

if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
# ensure the file exists
touch $JBOSS_CONSOLE
if [ ! -z "$SUBIT" ]; then
chown $JBOSS_USER $JBOSS_CONSOLE
fi
fi

if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
echo "WARNING: ignoring it and using /dev/null"
JBOSS_CONSOLE="/dev/null"
fi

#define what will be done with the console log
JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}

JBOSS_CMD_START="cd $JBOSS_HOME/bin; nohup $JBOSSSH"

if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
export PATH=$PATH:$JAVAPTH
fi

if [ ! -d "$JBOSS_HOME" ]; then
echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
exit 1
fi

echo JBOSS_CMD_START = $JBOSS_CMD_START

function procrunning() {
procid=0
JBOSSSCRIPT=$(echo $JBOSSSH | awk '{print $1}' | sed 's/\//\\\//g')
for procid in `/sbin/pidof -x "$JBOSSSCRIPT"`; do
ps -fp $procid | grep "${JBOSSSH% *}" > /dev/null && pid=$procid
done
}

stop() {
pid=0
procrunning
if [ $pid = '0' ]; then
echo -n -e "\nNo JBossas is currently running\n"
exit 1
fi

RETVAL=1

# If process is still running

# First, try to kill it nicely
for id in `ps --ppid $pid | awk '{print $1}' | grep -v "^PID$"`; do
if [ -z "$SUBIT" ]; then
kill -15 $id
else
$SUBIT "kill -15 $id"
fi
done

sleep=0
while [ $sleep -lt 120 -a $RETVAL -eq 1 ]; do
echo -n -e "\nwaiting for processes to stop";
sleep 10
sleep=`expr $sleep + 10`
pid=0
procrunning
if [ $pid == '0' ]; then
RETVAL=0
fi
done

# Still not dead... kill it

count=0
pid=0
procrunning

if [ $RETVAL != 0 ] ; then
echo -e "\nTimeout: Shutdown command was sent, but process is still running with PID $pid"
exit 1
fi

echo
exit 0
}

case "$1" in
start)
cd $JBOSS_HOME/bin
if [ -z "$SUBIT" ]; then
eval $JBOSS_CMD_START 2>&1 >>${JBOSS_LOG} &
else
$SUBIT "$JBOSS_CMD_START 2>&1 >> ${JBOSS_LOG} &"
fi
;;
stop)
stop
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 (start|stop|restart|help)"
esac

Tuesday, May 11, 2010

Alfresco - creating the alfresco mysql database

cd /opt/Alfresco/extras/databases/mysql

mysql -u root -p < db_setup.sql

Wednesday, March 10, 2010

Alfresco - MySQL and LDAP configuration

LDAP notes
As per:
http://wiki.alfresco.com/wiki/Alfresco_Subsystems#Configuring_Subsystemshttp://forums.alfresco.com/en/viewtopic.php?f=9&t=25377&p=82530&hilit=ldap#p82530 you are NOT SUPPOSED to edit ../WEB-INF/ files under Alfresco 3.2 systems. Editing any files under ../WEB-INF/.. will not disable it - it will break the subsystem as you are removing one of the defaults referenced by the Spring configuration.

I want to authenticate users against Active Directory.
I do not use Single Sign On.
I am not sure whether I want to query groups, etc.
I do not want to change Active Directory password from Alfresco.

So my basic ldap configuration, in
alfresco-global.properties, is:
authentication.chain=ldap1:ldap-ad

You first need to makedir these directories:
subsystems/Authentication/ldap/ldap-ad under /opt/Alfresco/tomcat/shared/classes/alfresco/extension/
Then you need to copy
/opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/Authentication/ldap-ad/ldap-ad-authentication.properties to /opt/Alfresco/tomcat/shared/classes/alfresco/extension/subsystems/Authentication/ldap/ldap-ad
since your authentication.chain follows this directory path.
ldap1:ldap is authentication folder : authentication type

By default,
the default product configuration has a simple chain with one member. This is an instance of the alfrescoNtlm subsystem type with ID alfrescoNtlm1.

This is expressed in the built-in defaults (in /opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/repository.properties) as

authentication.chain=alfrescoNtlm1:alfrescoNtlm

To add log4j LDAP debugging, you need to add the following to /opt/Alfresco/tomcat/
webapps/alfresco/WEB-INF/classes/log4j.properties
#LDAP Server Debug
log4j.logger.org.alfresco.repo.security.authentication.ldap=debug



MySQL notes:
  • To set alfresco user password for MySQL:
mysql> set password for 'alfresco'@'localhost' = PASSWORD('newpassword');  

  • With community 3.2r2, in alfresco-global.properties, the database driver probably reads:
db.driver=org.gjt.mm.mysql.Driver This is for older Alfresco versions and my not connect to new MySQL versions. To fix, change db.driver to:
db.driver=com.mysql.jdbc.Driver

Verify that you have mysql-connector-java-###-##.jar installed.
It should be located in /opt/Alfresco/tomcat/lib/








Alfresco installation - MySQL

Another piece of info that the Alfresco Wiki hides is that
you need to grant the alfresco user privileges to the alfresco database.
mysql> grant all privileges on alfresco.* to
'alfresco'@'%' identified by 'alfresco';

Query OK, 0 rows modified (0.00sec)
mysql> grant all privileges on alfresco.* to
'alfresco'@'localhost' identified by 'alfresco'
;
Query OK, 0 rows modified (0.00sec)

Alfresco Notes - installing pdf2swf

From alfresco.log:
12:34:14,358 ERROR [org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker] Failed to start a runtime executable content transformer:
Execution result:
os: Linux
command: [/opt/Alfresco/bin/pdf2swf, -V]
succeeded: false
exit code: 1
out:
err: Cannot run program "/opt/Alfresco/bin/pdf2swf": java.io.IOException: error=2, No such file or directory

You will need to install pdf2swf.
You can get the tar.gz from here: http://www.swftools.org/download.html
I used the newest development snapshot.
You will need a bunch of devel packages as dependencies, something the swftools doesn't tell you in their FAQ. THe FAQ will tell you that you need freetype and jpeglib, but you will need others too. http://wiki.swftools.org/index.php/FAQ
Download the tar.gz and run:
# tar -zvxf swftools-0.x.x.tar
# cd swftools-0.x.x
# ./configure

You will need gcc, gcc-devel, gcc-c++, gcc-c++-devel, gdb, freetype, freetype-devel, libjpeg, ligjpeg-devel, giflib, giflib-devel, giflib-utils, make, gd, gd-progs, gd-devel, fontconfig-devel, libpng, libpng-devel, libgomp and whatever dependency that might pop up.
At that point, when ./configure runs cleanly without any errors, will you be able to run:
# make
# make install

Then you will need to update /opt/Alfresco/tomcat/shared/classes/alfresco-global.properties
and update:
swf.exe=/usr/local/bin/pdf2swf (or where you installed pfd2swf)


Alfresco Notes - correcting ImageMagick on RedHat/Centos/Fedora

Alfresco Notes
From /opt/Alfresco/alfresco.log:
12:34:14,295 ERROR [org.alfresco.repo.content.transform.magick.AbstractImageMagickContentTransformerWorker] ImageMagickContentTransformerWorker not available: 02080000 Failed to perform ImageMagick transformation:
Execution result:
os: Linux
command: [/usr/local/bin/convert, /opt/Alfresco/tomcat/temp/Alfresco/ImageMagickContentTransformerWorker_init_source_5773432174191933902.gif[0], /opt/Alfresco/tomcat/temp/Alfresco/ImageMagickContentTransformerWorker_init_target_2492752320130895971.png]
succeeded: false
exit code: 1
out:
err: Cannot run program "/usr/local/bin/convert": java.io.IOException: error=2, No such file or directory

To fix:
yum install ImageMagick ImageMagick-devel
cd /usr/local/bin/convert
ln -s /usr/bin/convert .

This will create a symlink to /usr/bin/convert and fix the error.

Wednesday, March 18, 2009

Office 2007 on Fedora 9

yum install wine wine-core wine-tools wine-desktop cabextract

will run dependency check and will probably also download and install wine-jack, wine-capi, wine-nas, wine-ldap, wine-cms, wine-pulseaudio, wine-twain

Install winetricks:

Winetricks is a small SH script which will go on the internet and automatically fetch and install Microsoft DLLs and Libraries into Wine with almost no hassle at all! To download it directly, type the following commands:

wget http://www.kegel.com/wine/winetricks

chmod +x ./winetricks

this will install a whole slew of .dll's and other MS related stuff in your home directory.


Utilize winetricks:

This will setup all necessary libraries and DLLs that Office 2007 will need to run properly:

./winetricks gdiplus riched20 riched30 msxml3 msxml4 msxml6 corefonts tahoma vb6run vcrun6 msi2

Insert Office 2007 Disk and Run Setup!

Now that we have all of the DLLs necessary to run the Installer, let us do so!

wine pathToCD/setup.exe

From here on out, you should be good to go! The installer should run and install everything just as if it was a Windows system!