Run open office as service in Ubuntu.

First You have to create a service for start openoffice. I have created a service under /etc/init.d it called OpenOffice. Script looks like

#!/bin/bash
   
### BEGIN INIT INFO
# Provides:          dovecot
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: dovecot
# Description:       dovecot pop & imap daemon
### END INIT INFO
    # 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=/opt/openoffice4/program
    SOFFICE_PATH=$OOo_HOME/soffice
    PIDFILE=/home/taria/soffice.bin.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
Then
Exit the text editor saving the file as you do.  Now make the script executable:
sudo chmod 0755 /etc/init.d/OpenOffice
Make it start automatically on reboot by executing this command:

sudo update-rc.d OpenOffice defaults
It can now auto start during OS boot. you can also start it by executing
/etc/init.d/OpenOffice start
/etc/init.d/OpenOffice stop

Comments

Popular posts from this blog

How to run ofbiz as ubuntu Service.

JPA vs Spring JPA vs Spring Data JPA vs Hibernate

Java Array Interview Questions for Entry-Level Developers Part 01