LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Creating a startup script for Openoffice in headless mode (https://www.linuxquestions.org/questions/linux-newbie-8/creating-a-startup-script-for-openoffice-in-headless-mode-923882/)

arthurfabre 01-15-2012 07:27 AM

Creating a startup script for Openoffice in headless mode
 
Hello,

I have installed openoffice via "yum install openoffice.org-headless" which installed openoffice as a dependency.
Openoffice should be installed, except I can't figure out how to stop or start it.

Running openoffice.org3 as some tutorials state renders a "command not found"

Other tutorials state I should create a .sh file in /etc/init.d/ to install openoffice as a service except the supplied file is for debian and doesn't seem to work on Centos 6.

Does anyone know where I could find such a file or where I could learn how to do it myself?

Thanks a lot!

Arthur

catkin 01-15-2012 08:20 AM

Presuming that you want to run an OOo process as a server, here's the command I use to start it for local use by unoconv on Debian Squeeze ($soffice_port is the port it should listen on, commonly 2002):
Code:

soffice -headless -accept="socket,host=127.0.0.1,port=$soffice_port;urp;" -nofirststartwizard &
Here are a couple of bash functions that my be useful (msg is a generalised messaging function).
Code:

#--------------------------
# Name: start_soffice_server
# Purpose: starts an OpenOffice.org server
# Return: 0 if OpenOffice.org server is started; otherwise calls finalise
#--------------------------
function start_soffice_server {
    local buf rc

    soffice -headless -accept="socket,host=127.0.0.1,port=$soffice_port;urp;" -nofirststartwizard &
    disown $!        # Suppresses the bash job control job ending message
    for (( i=0; i<wait_for_soffice_server; i++ ))
    do
        sleep 1
        ck_soffice_server && return 0
    done
    msg E "Timed out waiting for $wait_for_soffice_server seconds for OpenOffice.org server to start"
    finalise 1

}  # end of function start_soffice_server

#--------------------------
# Name: ck_soffice_server
# Purpose: checks whether a OpenOffice.org server is running
# Return: 0 if one is running; 1 if not
#--------------------------
function ck_soffice_server {
    local buf

    # Is a soffice.bin process listening on the port?
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    buf=$( netstat --all --numeric --program --tcp 2>/dev/null | grep ":$soffice_port .*LISTEN" )
    if [[ $buf =~ /soffice.bin$ ]]; then
        return 0
    else
        return 1
    fi

}  # end of function ck_soffice_server

Regards the boot script, I no longer have access to a CentOS system but do have a log for a CentOS 5.5 system which records creating boot scripts in /etc/rc.d/init.d/ with 544 permissions and using chkconfig to install links to them in appropriate directories.

arthurfabre 01-15-2012 08:58 AM

Thanks for the quick reply!

I think I've finally figured it out - I hadn't installed the openoffice.org-writer and openoffice.org-draw packages.

Removed everything with
Code:

yum remove openoffice*
followed by
Code:

yum install openoffice.org-headless openoffice.org-writer openoffice.org-draw
After that your command
Code:

soffice -headless -accept="socket,host=127.0.0.1,port=$soffice_port;urp;" -nofirststartwizard &
worked fine.

Thanks a lot for your help!

catkin 01-15-2012 11:40 AM

At simplest, you can add the command to /etc/rc.d/rc.local.

For a more fully featured solution there may be a /etc/init.d/skeleton file (if not, try find /etc/ -name '*skeleton*' ) to use as an example for a full boot script.

arthurfabre 01-15-2012 11:56 AM

I'll look into that. For the moment I've generated a simple startup script with webmin :D

Thanks for all your help!


All times are GMT -5. The time now is 07:14 PM.