1

I'm trying to start darkice each time the raspberry pi is booted.

I created a file /etc/systemd/darkice.service like this

description = darkice_radio_streamer

After = multi-user.target

[Service]
#Type=simple
Type = Idle
WorkingDirectory=/home/pi 
ExecStart=/usr/bin/sh /home/pi/startup.sh
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
User=root
Group=root
LimitNOFILE=10240
LimitFSIZE=infinity

[Install]
WantedBy=multi.target

The startup.sh file has one line

/usr/bin/darkice -c /home/pi/darkice_current.cfg

I enabled the service using

sudo systemctl enable darkice

When logged in as the "pi" user via SSH, I can start the service like this

sudo systemctl start darkice

But when I restart the pi using

sudo shutdown -r now

The service doesn't start.

sudo systemctl status darkice

Returns

ESCOD ● darkice.service Loaded: loaded (/etc/systemd/system/darkice.service; enabled; vendor preset: enabled Active: inactive (dead)

I can now type

sudo systemctl start darkice

and the service starts.

I tried also starting the service as User/Group pi but that didn't help.

  • How can I start the service on boot without having to start it manually after each reboot?
  • Is there some other way I could start it?
4
  • what if you change After = multi-user.target to After=network.target - note: I assume those first two lines are actually after [unit] which you haven't shown in your question) - also, personally, I wouldn't run darkice as root, there shouldn't be any need to do so Jan 10, 2023 at 23:34
  • Thanks for the reply. I tried After=network.target earlier, that did not change anything. Regarding running as root: If I start darkice as a pi user (with sudo rights) it asks for my password to sudo itself.. - my guess is that is has something to do with accessing the audio. Since the pi's only job is to stream the audio via darkice, I'm not too worried about running it as root.
    – 576i
    Jan 10, 2023 at 23:40
  • I gather you've shown the complete output of systemctl status darkice - no actual errors shown? Is there any useful logs in any /var/log file to indicate what the issue is? Just to test, can you put a sleep 30 above /usr/bin/darkice -c /home/pi/darkice_current.cfg in the shell script Jan 10, 2023 at 23:49
  • Thanks, I did also try a sleep command (of 15 seconds) in the sh file before posting here without success. There are 5 warnings in the systemctl status darkice, (about blank lines and sections) but the script runs when started manually. The device is not local and I can currently not access it, I'll try to add these the next time I get access.
    – 576i
    Jan 11, 2023 at 8:28

1 Answer 1

0

The problem was that icecast isn't started properly directly after boot. Starting it before darkice is needed.

So the startup.sh needs to look like this

/etc/init.d/icecast2 start
/usr/bin/darkice -c /home/pi/darkice_current.cfg

See: https://forums.raspberrypi.com/viewtopic.php?t=159760

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.