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?
After = multi-user.target
toAfter=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 rundarkice
as root, there shouldn't be any need to do soAfter=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.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 asleep 30
above/usr/bin/darkice -c /home/pi/darkice_current.cfg
in the shell scriptsystemctl 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.