OpenOffice - Create a startup service script



OpenOffice Service Script:


After the OpenOffice instalation, if there is no startup script for OpenOffice you can follow the steps shown below to make a startup script.


First of all you have to locate the soffice binary file.

[root@server ~]# locate soffice.bin
/usr/lib/openoffice.org3/program/soffice.bin

Create a file with the following contents in /etc/init.d/ directory. Here i am creating a file named 'soffice'.

# vim /etc/init.d/soffice

==================================================================================================================
#!/bin/bash
# chkconfig: 345 20 80
# description: init.d script for headless openoffice.org (2.3+ for RHEL5 64bit)
#
# processname: soffice
#
# source function library
. /etc/rc.d/init.d/functions

RETVAL=0

SOFFICE_PATH='/usr/lib/openoffice.org3/program'
SOFFICE_ARGS='-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager -headless -nofirststartwizard -nologo'
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

==================================================================================================================

To give executable permission to the script.

# chmod +x /etc/init.d/soffice

To add the script 'soffice' to runlevel programs.

# chkconfig --add soffice

To start the 'soffice' service in startup.

# chkconfig soffice on


[root@server ~]# /etc/init.d/soffice restart
Stopping OpenOffice                                       [  OK  ]
Starting OpenOffice.org                                   [  OK  ]



You can verify whether the service is running or not by using the following command.

root@server ~$ ps aux | grep office

root      3529  0.0  0.0   4140   640 pts/4    S    01:28   0:00 /bin/sh /usr/bin/soffice -accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager -headless -nofirststartwizard -nologo
root      3546  0.5  3.2 580584 65116 pts/4    Sl   01:28   0:00 /usr/lib/openoffice/program/soffice.bin -accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager -headless -nofirststartwizard -nologo
root      3584  0.0  0.0   7668   820 pts/5    S+   01:29   0:00 grep --color=auto office

This entry was posted by Arun Ghosh. Bookmark the permalink.