Running OpenOffice From Terminal
From AlfrescoWiki
[edit] OpenOffice.org 2.3 and up
OpenOffice.org 2.3 and above no longer needs to use Xvfb. You can run the soffice command directly as below (if user alfresco is running Tomcat)
therefore you can just run (all on one line)
$ sudo -H -u alfresco /usr/lib/openoffice/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -nofirststartwizard
Note: if you receive the error "X11 error: Can't open display:" when running the above command, then you may need to install the "headless" OpenOffice.org package from your Linux distribution. On Ubuntu/Debian, this package is called openoffice.org-headless.
for older versions read on...
[edit] OpenOffice.org below 2.3
Some notes on how to run OpenOffice on a Linux terminal:
First, install Xvfb using your favourite method (i.e. aptitude, yum, up2date, emerge or source download), then run it with a command syntax similar to this:
Xvfb :1 -screen 0 1024x768x24 -fbdir /usr/src &
Note: You may need to pick different screen dimensions if Xvfb emits an error like this:
Fatal server error: Could not add screen 0
If this occurs, pick a screen size you know will be supported by looking at the modelines in your X configuration. For example, if you're running X.org, look in /etc/X11/xorg.conf for this information. Typically, problems like this will not arise.
If you are using OpenOffice 2 then the program must be registered before it can be used unless you use the option -nofirststartwizard. Registration must be completed by the user under which the process will normally run.
You can register OpenOffice in the following ways:
[edit] Manual registration, without a UI
Note, since Alfresco 2.0 using OpenOffice.org 2.0.x we have included a bypass flag in the startup of OpenOffice that negates the need to perform the registration.
OpenOffice kindly included the following startup flag that we now use:
-nofirststartwizard
[edit] OpenOffice.org 2.0.x
The instructions found here should work with all 2.0 versions of OpenOffice.org: http://documentation.openoffice.org/HOW_TO/misc/Troubleshooting_guide.html#13.Repeatedly%20prompted%20to%20register|outline
[edit] Older instructions
(Based on http://ui.openoffice.org/specification/product_registration.html )
Open the following file in your favourite text editor (e.g. vi or notepad):
C:\Program Files\OpenOffice.org 2.0\share\registry\data\org\openoffice\Office\Common.xcu
or (if you have run the Linux Quick Install)
<Alfresco install directory>/openoffice/share/registry/data/org/openoffice/Office/Common.xcu
or (if you did a manual install)
/usr/lib/openoffice/share/registry/data/org/openoffice/Office/Common.xcu
You should see:
<oor:component-data oor:name="Common" oor:package="org.openoffice.Office" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... <node oor:name="Help"> <node oor:name="Registration"> <prop oor:name="URL"> <value>http://www.openoffice.org/welcome/registration20.html</value> </prop> </node> </node> ... </oor:component-data>
Remove the URL value to disable the registration process, e.g.:
<node oor:name="Registration">
<prop oor:name="URL">
<value></value>
</prop>
</node>
[edit] Registration using graphical client (X11 forwarding)
If you struggle with the command line interface, you can enable X11 forwarding to your PC and the register using the graphical interface.
You will need an X11 client. If you don't have one, install MI/X (used as a windows X client) on your pc ( http://www.microimages.com/mix/download.htm - 14 day trial) or install xmins (http://www.iteisa.com/xmins/ - GPL)
Enable X11 forwarding in /etc/sshd/sshd_config on alfresco host. Then, in PUTTY (your ssh client), check SSH/Tunnels/Enable X11 Forwarding before logging in to your linux box. Then log in (as root).
Open MI/X on your pc.
in PUTTY:
[root@server ~]# xterm -display :0
You'll get a terminal window in MI/X
in that MI/X terminal window:
cd /opt/openoffice/programs
./soffice and follow the steps to register
Close openoffice and exit xterm.
[edit] Launching OpenOffice.org in a headless (non-graphical) display environment
Next, run OpenOffice, and use this display (from the OpenOffice install dir):
./soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -display :1 &
[edit] Modify OpenOffice.org start script
You may need to modify the OpenOffice startup script. Open
<alfresco install directory>/bin/start_oo.sh
Add
/usr/X11R6/bin/Xvfb :1 -screen 0 800x600x16 -fbdir /usr/src &
at the start of the file to start the Xvfb application
Change the line:
<oo install directory>/openoffice/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless &
to
<oo install directory>/openoffice/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -display :1 &
[edit] Modify OpenOffice.org stop script
You may also want to modify the stop script. Please note that this is a hack, but it works for me.
Add the following line to <alfresco install directory>/bin/stop_oo.sh
killall Xvfb
after
killall soffice.bin
Note: updated with info from hikenboots and RBramley.
[edit] RHEL 4 init.d script
[For whatever reason, my CE install didn't have the start_oo.sh script, so I wrote my own to boot the required services on system startup -- cricalix]
Unfortunately, the daemon() function in the RHEL4 scripts doesn't appear to work with Xvfb or soffice. The neat Debian start-stop-daemon which can handle pidfiles etc also doesn't exist.
#!/bin/bash
# Boot open office so that Alfresco can do transforms.
# chkconfig: 2345 55 25
# description: OpenOffice Headless
#
# processname: soffice
# source function library
. /etc/rc.d/init.d/functions
RETVAL=0
VDISPLAY='99'
SOFFICE_PATH='/opt/openoffice.org2.2/program'
SOFFICE_ARGS1="-nofirststartwizard -nologo -headless -display :$VDISPLAY "
SOFFICE_ARGS2='-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager'
SOFFICE_PIDFILE=/var/run/soffice.bin.pid
XVFB=/usr/X11R6/bin/Xvfb
XVFB_ARGS=":$VDISPLAY -screen 0 800x600x8 -fbdir /var/run"
XVFB_PIDFILE=/var/run/xvfb.pid
start_soffice() {
echo -n $"Starting OpenOffice"
$SOFFICE_PATH/soffice $SOFFICE_ARGS1 $SOFFICE_ARGS2 >/dev/null 2>&1 &
[ $? -eq 0 ] && echo_success || echo_failure
pidof soffice.bin > $SOFFICE_PIDFILE
echo
}
start_xvfb() {
echo -n $"Starting Xvfb"
$XVFB $XVFB_ARGS >/dev/null 2>&1 &
[ $? -eq 0 ] && success || failure
pidofproc Xvfb > $XVFB_PIDFILE
echo
}
start() {
start_xvfb
sleep 3
start_soffice
}
stop() {
echo -n $"Stopping OpenOffice"
killproc soffice.bin
echo
echo -n $"Stopping Xvfb"
killproc Xvfb
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
esac

