#!/sbin/openrc-run
# Copyright 2021 Gentoo Foundation

description="The python unogenerator module daemon"
pidfile="/var/run/unogenerator.pid"

depend() {
	use net
}

start() {
	ebegin "Starting unogenerator"

	for i in  $(seq 1 $INSTANCES)
	do
		PORT=$((FIRST_PORT+i-1))
		echo "   Launching libreoffice service in port $PORT"
		/usr/bin/loffice --accept="socket,host=localhost,port=$PORT;urp;StarOffice.ServiceManager"  -env:UserInstallation=file:///tmp/l$PORT --headless --nologo &
	done
	eend $?

}
stop() {
	ebegin "Stopping unogenerator"
	pkill -f ";urp;StarOffice.ServiceManager"
	eend $?

}