-
-
Save Eitz/39fe5b132f06bde22a17e2a6811e9beb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
# Modified by Richard W. Eitz | |
# | |
# Installation: | |
# $ sudo wget --output-document=/etc/init.d/soffice https://gist.githubusercontent.com/Eitz/39fe5b132f06bde22a17e2a6811e9beb/raw/soffice?v=2 | |
# $ sudo chmod +x /etc/init.d/soffice | |
# $ sudo chkconfig soffice on | |
# $ sudo service soffice start | |
# | |
USER=www-data | |
SOFFICE_PATH=/usr/bin/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