Wednesday, March 03, 2010

Starting OO in headless with Version OpenOffice 3.0 ++

Starting with OO 3.0 you do not need Xvfb anymore you can just use this:

* for Linux: /path/to/openoffice/program/soffice.bin -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service"
* for Mac OS X: /path/to/openoffice.app/Contents/!MacOS/soffice.bin -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service"
* for Windows: soffice.exe -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service"

Linux (Debian,Ubuntu)
Open Office 2.4 Debian, Ubuntu

There are some improvements related to Openoffice 2.4 version. If you have to run old versions of Openoffice for any reason, please find the old section below. With 2.4, no more xvfb framebuffer needed.
Installation steps (based on Etch 4.0 i386)

1. Set backports for packages

* Check your Debian version, find suitable backport source
* vi(or nano or pico or your very favorite editor) /etc/apt/sources.list
* add this line
* deb http://www.backports.org/debian etch-backports main contrib non-free
* run apt-get update

1. Install packages

* Be sure all packages tagged with 2.4.0-4~bpo40+1
* openoffice.org-headless,
* openoffice.org-base, openoffice.org-writer, openoffice.org-calc, openoffice.org-impress, openoffice.org-draw, openoffice.org-math, openoffice.org-filter-mobiledev, openoffice.org-filter-binfilter, msttcorefonts, pstoedit, libpaper-utils, ttf-dejavu

1. Write startup script for test

* vi ooo.sh

unset DISPLAY
/usr/lib/openoffice/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -nofirststartwizard

* chmod +x ooo.sh

1. Run the oOo server as root.

* sh ooo.sh
* Check if server started with netstat -an | grep 8100
* Should seem like tcp 0 0 127.0.0.1:8100 0.0.0.0:* LISTEN
* Check you have soffice process running ps aux | grep soffice

1. Test the conversion from command line

* cd /usr/lib/red5/webapps/openmeetings/jod/
* cp /home/userx/testme.ppt . (figure out the copy ppt file to your server, winscp?)
* java -jar jodconverter-cli-2.2.0.jar -f pdf testme.ppt
* The result normally should be like below

com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection connect
INFO: connected
com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection disposing
INFO: disconnected

1. Login to openmeetings and check the conversion from there too.

* Be sure that you select correct file type to convert. For example, pdf files NOT converted by OO but with swftools pdf2swf. Check available file formats from http://www.artofsolving.com/opensource/jodconverter

Check List, Pay ATTENTION to this List!!!

* run ooo.sh as root otherwise converted document cant be written.
* Dont mess with directory permissions of upload, uploadtemp and jod. DO NOT left any file world writable on your behind.
* If your app name is other then "openmeetings" you should find

webapp/src/app/org/openmeetings/app/remote/Application.java line 66 and change to your context (will be fixed in svn)

* check webapps/openmeetings/jod/ dir. You'll see
o BATCHTHUMB_date_time_stamp_thumbnail.sh
o PDFCONVERT_date_time_stamp_jodconverter.sh
o SWFCONVERT_date_time_stamp_swfconverter.sh
o THUMB_date_time_stamp_thumbnail.sh
* Those files created on the fly. Do not attempt to play with jodconverter2.sh
* Check command line error codes;
o com.sun.star.task.ErrorCodeIOException; Be sure all packages installed, check ooo.sh run by root.
o com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one; Be sure all packages installed.
* Always watch openmeetings.log to see what really goes on. tail -f /usr/lib/red5/openmeetings.log from your console.

Todo List

* Create Debian init script for safe oOo operation
* Understand this, why numbered list and bullet item couldnt be used together and always you have repeated number one in wiki :)

Install Open Office Service on Debian/(K)Ubuntu (versions > 2.3)

1. Install OpenOffice-Headless as root (through su, sudo, etc.):

sudo apt-get install openoffice.org-headless

2. Create and edit a file named openoffice.sh (for example) with you favorite editor over /etc/init.d:

vi /etc/init.d/openoffice.sh

#!/bin/bash
# openoffice.org headless server script
#
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: openoffice
#
# Author: Vic Vijayakumar
# Modified by Federico Ch. Tomasczik
#
OOo_HOME=/usr/bin
SOFFICE_PATH=$OOo_HOME/soffice
PIDFILE=/var/run/openoffice-server.pid

set -e

case "$1" in
start)
if [ -f $PIDFILE ]; then
echo "OpenOffice headless server has already started."
sleep 5
exit
fi
echo "Starting OpenOffice headless server"
$SOFFICE_PATH -headless -nologo -nofirststartwizard -accept="socket,host=127.0.0.1,port=8100;urp" & > /dev/null 2>&1
touch $PIDFILE
;;
stop)
if [ -f $PIDFILE ]; then
echo "Stopping OpenOffice headless server."
killall -9 soffice && killall -9 soffice.bin
rm -f $PIDFILE
exit
fi
echo "Openoffice headless server is not running."
exit
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0

3. Change the permssions to this file:

chmod 0755 /etc/init.d/openoffice.sh

4. Install openoffice.sh init script links:

update-rc.d openoffice.sh defaults

5. Start the service:

/etc/init.d/./openoffice.sh start

6. You can see if openofice is running with this command:

netstat -nap | grep office

You should get something like this:

tcp 0 0 127.0.0.1:8100 0.0.0.0:*
LISTEN 2467/soffice.bin


****copas from http://code.google.com/p/openmeetings/wiki/OpenOfficeConverter*****