Chris Schuld's Blog

personal musings on the composition of software

Written By: Chris Schuld Thursday, October 9th, 2008

For a recent project I needed to perform document translations from DOC to PNG which requires an essential intermediate step to PDF. The transformations required us to go to from DOC to PDF which can easily be done very nicely using openoffice 2.3 in a headless configuration. The downside is you need a process running on a machine which you can connect to to make the transformation.

Here is the init.d script for starting up the soffice.bin (soffice) program in a headless mode:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# chkconfig: 345 20 80
# description: init.d script for headless openoffice.org (2.3+ for RHEL5 32bit)
#
# processname: soffice
#
# source function library
. /etc/rc.d/init.d/functions
 
RETVAL=0
SOFFICE_PATH='/usr/lib/openoffice.org/program'
SOFFICE_ARGS='-accept="socket,host=localhost,port=8100;urp" -headless -nofirststartwizard'
SOFFICE_PIDFILE=/var/run/soffice.bin.pid
 
start_soffice() {
       echo -n $"Starting OpenOffice.org"
       $SOFFICE_PATH/soffice.bin $SOFFICE_ARGS >/dev/null 2>&1 &
       [ $? -eq 0 ] && echo_success || echo_failure
       pidof soffice.bin & $SOFFICE_PIDFILE
       echo
}
start() {
       start_soffice
}
stop() {
       echo -n $"Stopping OpenOffice"
       killproc soffice.bin
       echo
}
case "$1" in
       start)
               start
               ;;
       stop)
               stop
               ;;
       restart)
               stop
               start
               ;;
       *)
               echo $"Usage: $0 {start|stop|restart}"
esac

NOTE: in 64bit the lib path has a ’64′ in it so

SOFFICE_PATH='/usr/lib/openoffice.org/program'

becomes

SOFFICE_PATH='/usr/lib64/openoffice.org/program'

6 Responses to " RHEL5 init (init.d) script for OpenOffice.org (2.3+) "

  1. Jorge Williams says:

    Hi Chris,

    I don’t think it’s a good idea to run soffice as root.

    I’d suggest creating a user “soffice” and trying something like:

    su – soffice -c “$SOFFICE_PATH/soffice.bin $SOFFICE_ARGS” /dev/null &

    -jOrGe W.

  2. Jorge Williams says:

    Whoops… I mean

    su – soffice -c “$SOFFICE_PATH/soffice.bin $SOFFICE_ARGS” < /dev/null &> /dev/null &

  3. Chris Schuld says:

    @Jorge,

    Thanks! Agreed 100%; thanks for the update/suggestion!

  4. Surj says:

    Also add the param -nofirststartwizard to stop it asking you to register, e.g.:

    SOFFICE_ARGS=’-accept=”socket,host=localhost,port=8100;urp” -headless -nofirststartwizard’

  5. bill says:

    I’m trying this on fedora 10 w/ oo3 (fedora’s 3.0.1-15.3 version) and i can’t seem to get it to work. i have the following oo3 rpms installed:

    openoffice.org-ure-3.0.1-15.3.fc10.i386
    openoffice.org-headless-3.0.1-15.3.fc10.i386
    openoffice.org-core-3.0.1-15.3.fc10.i386
    openoffice.org-brand-3.0.1-15.3.fc10.i386

    so my command line looks like:

    /usr/lib/openoffice.org3/program/soffice.bin -headless -nofirststartwizard -accept=”socket,host=localhost,port=8100;urp;StarOffice.Service”

    if i run that as root from the console, it binds to 8100.

    if i run the init script (w/ the same commandline) it doesn’t bind to 8100.

    any ideas?

  6. bill says:

    So I changed the init script line to run directly w/ the options, no variables:

    ${SOFFICE_PATH}/soffice.bin -headless -nofirststartwizard -accept=”socket,host=localhost,port=8100;urp;StarOffice.Service” > /dev/null 2>&1 &

    and it works fine. dunno what the deal is.

Leave a Reply

About Chris

Chris Schuld

Thank you for visiting my website. I use this site for a myriad of things: maintaining software I have open sourced, connecting with my readers and friends and documenting all of this little things "I wished I would have written down." You can read more about me or contact me.


thanks for visiting... happy coding

Recent Comments