OK, so this is what I did.
1) Build OSPi Firmware as per normal but select “No” when prompted to auto-start OpenSprinkler.
$ sudo ./build.sh OSPI
2) Create a Systemd configuration file to control the start-up of OSPi
$ sudo nano /etc/systemd/system/ospi.service
3) Add the following lines to the ospi.service file and then save the file
[Unit]
Description=OpenSprinkler Server
# After=weather.service apache2.service
[Service]
# ExecStart=/usr/bin/stdbuf -oL /home/peter/OpenSprinklerGen2/OpenSprinkler
ExecStart=/home/peter/OpenSprinklerGen2/OpenSprinkler
WorkingDirectory=/home/peter/OpenSprinklerGen2
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Note that in my setup, I need OSPi to wait until I have started the web server and weather service as I host these on my local RPi. Also, I use “stdbuf” to set the output from OSPi to be line buffered (i.e. -oL) so that diagnostic output is written immediately to the journal log file. Both of these may be unnecessary for you so have commented out. You will need to adjust the directories to your OSPi directory location.
4) Initialise the service and set to auto-start
$ sudo systemctl enable ospi.service
$ sudo systemctl start ospi.service
5) You can check that the service is running successfully with the systemctl command
$ systemctl status ospi.service
That should be it.
Pete