Auto-start darkice on raspberry pi

I just built a brand-new out of the package sdcard using the instructions I posted earlier, and except for some fat-fingering, it all worked.

Now it’s time to mess with systemd and get it to auto-start darkice when the RPi is rebooted or after power’s been reapplied after an outage.

This site is your friend for this work. Read it repeatedly.

We want the RPi upon power-up to auto-start darkice. If we can get that to work, then even when your 3-hour-drive remote monitoring site dies from lack of power, when and if the power returns darkice will come up again, and attempt to connect to railroadradio.net.

darkice is pretty simple, at least in terms of the basics. Invoking “darkice” at the command line is easy – but darkice needs to know where the darkice.cfg file is. As you may remember, in the last post I’d left the modified darkice.cfg file in the /etc folder, which is fine for me. The full command, to invoke darkice, is “darkice -c /etc/darkice1.cfg”.

Easy peasy, right? (Apologies to Richard Small for stealing his line)

I found it much harder to get systemd (not local.rc, or some script workaround) to invoke darkice reliably. And that’s because “that’s supposed to be the way it’s done in ‘modern’ Raspbian, so it seemed high time to learn it.

I want darkice to run as a system service, so the command line doesn’t get locked up running one app. I studied other xxx.service files on the web, and figured out what might be needed here. And here is it!

Make sure the following file is saved in /etc/systemd/system as darkice.service

When it’s saved there, you’ll need to remind systemd that it’s there, so next do

sudo systemctl enable darkice.service

While I don’t really know what this is doing, I imagine it’s setting a flag in systemd, or something more complicated, that lets systemd know that darkice.service is there and that it’s part of systemd.

Here’s the actual file contents for darkice.service

Having some technical difficulties, please stand by!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.