Skip to content

Instantly share code, notes, and snippets.

@jdewit
Last active March 21, 2021 03:38
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jdewit/9038765 to your computer and use it in GitHub Desktop.
Save jdewit/9038765 to your computer and use it in GitHub Desktop.
unoconv daemon
### BEGIN INIT INFO
# Provides: unoconvd
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: unoconvd Converting documents to PDF by unoconv
### END INIT INFO
#!/bin/sh
case "$1" in
status)
if [ $(ps ax | grep "/usr/lib/libreoffice/program/soffice.bin" | grep "accept=socket,host=127.0.0.1,port=2002;urp;StarOffice.ComponentContext" | wc -l) -gt 0 ]; then
echo "Unoconv listener active"
else
echo "Unoconv listener inactive"
fi
;;
start)
if [ $(ps ax | grep "/usr/lib/libreoffice/program/soffice.bin" | grep "accept=socket,host=127.0.0.1,port=2002;urp;StarOffice.ComponentContext" | wc -l) -gt 0 ]; then
echo "Unoconv listener already started."
else
/usr/bin/unoconv --listener &
echo "Unoconv listener started."
fi
;;
stop)
if [ $(ps ax | grep "/usr/lib/libreoffice/program/soffice.bin" | grep "accept=socket,host=127.0.0.1,port=2002;urp;StarOffice.ComponentContext" | wc -l) -gt 0 ]; then
killall soffice.bin
echo "Unoconv listener stopped."
else
echo "Unoconv isn’t running."
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: /etc/init.d/unoconvd {start|stop|restart|status}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment