#!/bin/sh

# Verify if there is another oood running and flush if not
# This will stop previous open offices running in the past.
if [ ! -f ${configuration:oood_pid}];
then
    PYTHONPATH=${configuration:openoffice_uno} ${configuration:openoffice_python} ${software_definition:oood_software}/start.py --flush > /dev/null 2>&1 /dev/null
fi

PYTHONPATH=${configuration:openoffice_uno} ${configuration:openoffice_python} ${software_definition:oood_software}/runserw.py $@

# After the previous command finish (--start or --stop), call start.py flush, this prevents leave openoffice and xvfb running after stop.
PYTHONPATH=${configuration:openoffice_uno} ${configuration:openoffice_python} ${software_definition:oood_software}/start.py --flush > /dev/null 2>&1 /dev/null