Page 1 of 1

Autostart OpenKM on boot - FreeBSD 9.0 RELEASE - 2012/02/28

PostPosted:Mon Feb 27, 2012 6:58 am
by okmuser
Hi Just thought of share the script I used for autostart OpenKM at boot in FreeBSD 9.0 RELEASE.

This is my /usr/local/etc/rc.d/openkm.sh
Code: Select all
#!/bin/sh
#
#
#

# PROVIDE: openkm
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable openkm:
#
# openkm_enable="YES"
#

. /etc/rc.subr

name=openkm
rcvar=`set_rcvar`

start_cmd="${name}_start"
stop_cmd="${name}_stop"

openkm_start()
{
	echo "Starting OpenKM...."
                 /home/okmuser/jboss/bin/run.sh -b 0.0.0.0 &

}

openkm_stop()
{
	echo "Shutting down OpenKM...."
                 /home/okmuser/jboss/bin/shutdown.sh -S

}

# set defaults

openkm_enable=${openkm_enable:-"NO"}

load_rc_config ${name}

JAVA_HOME="/usr/local/linux-sun-jdk1.6.0/";

export JAVA_HOME

run_rc_command "$1"
and add the following to /etc/rc.conf
Code: Select all
openkm_enable="YES"
For some reason openkm in FreeBSD doesn't start libreoffice at startup so at the moment I start soffice manually.

/usr/local/etc/rc.d/soffice.sh
Code: Select all
#!/bin/sh
#
#
#

# PROVIDE: soffice
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable soffice:
#
# soffice_enable="YES"
#

. /etc/rc.subr

name=soffice
rcvar=`set_rcvar`

command="/usr/local/lib/libreoffice/program/soffice[b]x[/b].sh"
# set defaults

soffice_enable=${soffice_enable:-"YES"}

load_rc_config ${name}

run_rc_command "$1"
and add the following to /etc/rc.conf
Code: Select all
soffice_enable="YES"
and create a sofficex file in /usr/local/lib/libreoffice/program/ with
Code: Select all
#!/bin/sh
#
/usr/local/lib/libreoffice/program/soffice "-accept=socket,host=127.0.0.1,port=2222,tcpNoDelay=1;urp;" -headless -nodefault 
-nofirststartwizard -nolockcheck -nologo -norestore &
please note the above code (/usr/local...... -norestore &) is on single line.

I haven't tried with soffice_flags for soffice, I will check and post if sucessful.

Hope this helps someone.

Cheers,

EDIT: last edited to improve OpenKM starting and shutting down process and modify Java to Sun Java as with OpenJDK I had some issues in properly starting OpenKM.war.

Re: Autostart OpenKM on boot - FreeBSD 9.0 RELEASE - 2012/02

PostPosted:Wed Feb 29, 2012 11:02 pm
by pavila
In recent OpenKM versions you don't need to start OpenOffice by yourself because this is handle automatically by OpenKM.

Re: Autostart OpenKM on boot - FreeBSD 9.0 RELEASE - 2012/07

PostPosted:Tue Jul 03, 2012 1:41 am
by okmuser
Updated for better shutdown process:
Code: Select all
#!/bin/sh
# Openkm startup Script

# PROVIDE: Openkm
# REQUIRE: mysql LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="Openkm"
rcvar=${name}_enable
Openkm_enable=${Openkm_enable-"NO"}

start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name

JAVA_HOME="/usr/local/openjdk6/";

export JAVA_HOME

procname="java"

Openkm_start(){
echo "Starting OpenKM....."
rm -r /alldata/programs/jboss/server/default/work &
rm -r /alldata/programs/jboss/server/default/tmp &
/usr/local/lib/libreoffice/program/soffice "--accept=socket,host=localhost,port=2222;urp;StarOffice.ServiceManager" --nologo --headless --nofirststartwizard &
su -m nobody -c /alldata/programs/jboss/bin/run.sh -b 0.0.0.0 & > /dev/null

}

Openkm_stop(){

echo "Stopping OpenKM....."
/alldata/programs/jboss/bin/shutdown.sh -S
killall -9 soffice.bin &
}


run_rc_command "$1"

Re: Autostart OpenKM on boot - FreeBSD 9.0 RELEASE - 2012/02

PostPosted:Wed Jul 04, 2012 6:19 pm
by jllort
I have added in our wiki with a link to this forum post.