On a headless RaspberryPi, I would like to automatically start radio on boot, without any human action. I have written this file as /etc/systemd/system/radio.service :
[Unit]
Description=Radio
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/mplayer http://audio.scdn.arkena.com/11016/fip-midfi128.mp3 &
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Unfortunately it doesn't work: after boot, doing systemctl status radio shows :
Loaded: loaded (/etc/systemd/system/radio.service; disabled)
Active: inactive (dead)
I think the Wants and After are necessary because an "up" network is required, as described here.
Should I change Type or RemainAfterExit? Or remove the & at the end of ExecStart? Something else?
systemctl enable radio. Does it start withsystemctl start radio? – Thomas Feb 07 '16 at 15:22systemctl start radio. But when I reboot, it doesn't start automatically. Instead the status showsLoaded: loaded (/etc/systemd/system/radio.service; disabled) Active: inactive (dead). – Basj Feb 07 '16 at 15:26&at the end of the binary. And I also would leaveRemainAfterExit=nowhich is the default. I'd rather would change toType=Simple. – Thomas Feb 07 '16 at 15:38