Skip to content

Instantly share code, notes, and snippets.

@kevinmartin
Forked from stuzart/gist:3787679
Last active July 11, 2018 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kevinmartin/6135525 to your computer and use it in GitHub Desktop.
Save kevinmartin/6135525 to your computer and use it in GitHub Desktop.
#!/bin/bash
# originally from: http://code.google.com/p/openmeetings/wiki/OpenOfficeConverter
# openoffice.org headless server script
#
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: openoffice
#
# Author: Vic Vijayakumar
# Modified by Federico Ch. Tomasczik
# Modified by Stuart Owen
# Modified by Kevin J. Martin
#
# Installation:
# $ sudo wget --output-file=/etc/init.d/soffice https://gist.github.com/KevinMartin/6135525/raw/soffice
# $ sudo chmod +x /etc/init.d/soffice
# $ sudo chkconfig soffice on
# $ sudo service soffice start
#
USER=www-data
OOo_HOME=/opt/libreoffice4.1/program
SOFFICE_PATH=$OOo_HOME/soffice
PIDFILE=/var/run/openoffice-server.pid
PROG=$(basename $0 | sed -e 's/^[SK][0-9][0-9]//')
set -e
start_soffice(){
if [ -f $PIDFILE ]; then
echo "OpenOffice headless server has already started."
sleep 1
exit
fi
echo $"Starting OpenOffice headless server as user $USER."
sudo -Hu $USER $SOFFICE_PATH --headless --nologo --nodefault --norestore --nocrashreport --nolockcheck --nofirststartwizard --invisible --accept="socket,host=127.0.0.1,port=8100;urp" & > /dev/null 2>&1
touch $PIDFILE
}
stop_soffice(){
if [ ! -f $PIDFILE ]; then
echo "OpenOffice headless server is not running."
sleep 1
exit
fi
echo "Stopping OpenOffice headless server."
killall -9 soffice.bin
rm -f $PIDFILE
}
case "$1" in
status)
if [ -f $PIDFILE ]; then
echo "OpenOffice headless server is (should be) running."
else
echo "OpenOffice headless server is (should be) stopped"
fi
;;
start)
start_soffice
;;
stop)
stop_soffice
;;
restart)
stop_soffice
sleep 1s
start_soffice
exit 0
;;
*)
echo $"Usage: $PROG {start|stop|restart|status}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment