You are not logged in.

#1 2011-12-26 20:31:41

csergec
Member
Registered: 2009-09-29
Posts: 62

LibreOffice Daemon

Hi

I have installed openmeetings.
I would like to start LibreOffice as a Daemon as openmeetings needs it when uploading files.

I wrote this deamon ( tried to... )

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

PID=$(pidof -o %PPID /usr/bin/soffice)
case "$1" in
  start)
    stat_busy "Starting Net LibreOffice Daemon"
    [ -z "$PID" ] && /usr/bin/soffice --headless --nologo --nofirststartwizard --accept="socket,host=localhost,port=8100;urp;StarOffice.service" &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon ooffice-net
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Net LibreOffice Daemon"
    [ ! -z "$PID" ] && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon ooffice-net
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

What happens is that starting it, the daemon is stuck at "Busy".

As you can see most of the code is a copy&paste of existing daemons...

What did I do wrong?

Thanks for your help


Serge

Offline

#2 2011-12-27 05:36:51

Stebalien
Member
Registered: 2010-04-27
Posts: 1,238
Website

Re: LibreOffice Daemon

You aren't forking it.

Change

&> /dev/null

to

> /dev/null &

Also, if possible, you really shouldn't be running libreoffice as root (use nobody).


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#3 2011-12-27 08:47:03

csergec
Member
Registered: 2009-09-29
Posts: 62

Re: LibreOffice Daemon

Hi Stebalien

With this change, it is still stuck at [busy].

For the second point, how can I make it run as nobody ?

Thank you

Serge

[EDIT]
Actually it "works" when changing to > /dev/null &.
But when stopping the daemon, it fails, when starting again the daemon [not restarting] I always get [done],
when retarting the daemon I get [fail] for stopping the daemon, and [done] for starting the daemon.
It seems that the daemon is never started...

Last edited by csergec (2011-12-27 08:57:22)

Offline

#4 2011-12-27 17:44:49

Stebalien
Member
Registered: 2010-04-27
Posts: 1,238
Website

Re: LibreOffice Daemon

/usr/bin/soffice is a symlink. You need to get the pid of /usr/lib/libreoffice/program/soffice.bin.

$ ls -l /usr/bin/soffice
lrwxrwxrwx 1 root root 36 Dec 19 05:11 /usr/bin/soffice -> /usr/lib/libreoffice/program/soffice*

Next time. If you want to know if a program is running, run

ps -eF|grep '<program>'

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#5 2011-12-27 18:30:06

csergec
Member
Registered: 2009-09-29
Posts: 62

Re: LibreOffice Daemon

Hi Stebalien

Thank you, it is working.
However, if I start the daemon, it works. If i start it again ( not restart ), I do not get the message telling me the deamon is already running but the [done] message.
I checked with ps, the first pid is running and no new one is starting. So i can live with it.
Stopping and restarting the daemon work too.

Serge

Last edited by csergec (2011-12-27 19:11:50)

Offline

Board footer

Powered by FluxBB