Launching OpenOffice 3 as a headless service on startup

Hello,
I am running FreeBSD 9.0. I have installed OpenOffice 3 from the ports. I am running a Tomcat server that requires Openoffice to start as a headless service on boot.

I read that on linux systems this can be done by creating a script under /usr/local/etc/rc.d and then including it in /etc/rc.conf. One also has to install openoffice-headless for this to work.

However, I am totally failing to get it working on BSD. Does anyone have any tips or example files?

Thanks.
 
Solved

OK - here is how I sorted this out (with some help from a previous FreeBSD forums poster on this subject: http://lists.freebsd.org/pipermail/freebsd-questions/2012-March/239614.html):

Create a file called "libreoffice" in /usr/local/etc/rc.d

Enter the following in that file:
Code:
#!/bin/sh
#

# PROVIDE: libreoffice
# REQUIRE: cleanvar usr
# KEYWORD: shutdown

. /etc/rc.subr

soffice_path="/usr/local/lib/libreoffice/program"
name="soffice"
soffice_user="PUT YOUR USER HERE"
procname="${soffice_path}/oosplash.bin"
rcvar=libreoffice_enable
pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"
command_args="-p $pidfile"
command_args="$command_args ${soffice_path}/${name}"
command_args="$command_args '--accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;StarOffice.Service'"
command_args="$command_args --nologo --headless --nofirststartwizard --invisible"
command_args="$command_args --nolockcheck --norestore"
stop_precmd="${name}_prestop"
soffice_prestop(){
    # kill first child process
    pkill -P `cat $pidfile`
}


load_rc_config $name
run_rc_command "$1"
Make the file permissions 0755. Save the file. Then add the following line to /etc/rc.conf:
Code:
libreoffice_enable="YES"

When rebooting, soffice should show up as starting in headless mode with the rest of the rc scripts.
 
Back
Top