I've installed ubuntu server on a raspberry PI4. I would like this raspberry to run an audio file at boot (without me logging in).
I have created an audio.sh file with the following:
#!/bin/sh
cvlc --loop --intf=dummy /home/user/musica.mp3
then i created a service that starts (audio.service):
[Unit]
Description=Servizio Musica Showroom
[Service]
ExecStart=/home/user/audio.sh
[Install]
WantedBy=default.target
this was giving pulseaudio errors at boot up so I also created this service:
[Unit]
Description=Pulse Audio
[Service]
Type=notify
ExecStart=pulseaudio --daemonize=no --system --realtime --log-target=journal
[Install]
WantedBy=multi-user.target
but it's still not running. I can see both start at bootup but I can't here the music (if I simply run the .sh file after login it works).
After login i run "sudo systemctl --system status audio.service" I have the following output:
● audio.service - Servizio Musica Showroom
Loaded: loaded (/etc/systemd/system/audio.service; enabled; preset: enabled)
Active: active (running) since Mon 2023-07-31 14:04:13 UTC; 9min ago
Main PID: 1206 (audio.sh)
Tasks: 5 (limit: 9237)
Memory: 26.3M
CPU: 12.027s
CGroup: /system.slice/audio.service
├─1206 /bin/sh /home/user/audio.sh
└─1207 /usr/bin/vlc -I dummy --loop --intf=dummy /home/user/musica.mp3
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000aaab0f68b4d0] main interface error: no suitable interface module
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000aaab0f596230] main libvlc error: interface "globalhotkeys,none" initializa>
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000aaab0f68b4d0] dummy interface: using the dummy interface module...
Jul 31 14:04:13 ubuntu audio.sh[1207]: ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Access deni>
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000aaab0f665c00] alsa audio output error: cannot open ALSA device "default": >
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000aaab0f665c00] main audio output error: Audio output failed
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000aaab0f665c00] main audio output error: The audio device "default" could no>
Jul 31 14:04:13 ubuntu audio.sh[1207]: Connection refused.
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000aaab0f665c00] main audio output error: module not functional
Jul 31 14:04:13 ubuntu audio.sh[1207]: [0000ffff7cc1e6f0] main decoder error: failed to create audio output
and if i run "sudo systemctl --system status pulseaudio.service"
I get the following output:
● pulseaudio.service - Pulse Audio
Loaded: loaded (/etc/systemd/system/pulseaudio.service; enabled; preset: enabled)
Active: active (running) since Mon 2023-07-31 13:57:09 UTC; 17min ago
Main PID: 686 (pulseaudio)
Tasks: 3 (limit: 9237)
Memory: 29.5M
CPU: 579ms
CGroup: /system.slice/pulseaudio.service
└─686 pulseaudio --daemonize=no --system --realtime --log-target=journal
Jul 31 13:57:06 ubuntu pulseaudio[686]: Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/>
Jul 31 13:57:09 ubuntu pulseaudio[686]: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': No such file>
Jul 31 13:57:09 ubuntu pulseaudio[686]: Failed to load authentication key '/var/run/pulse/.config/pulse/cookie': No su>
Jul 31 13:57:09 ubuntu pulseaudio[686]: Failed to open cookie file '/var/run/pulse/.pulse-cookie': No such file or dir>
Jul 31 13:57:09 ubuntu pulseaudio[686]: Failed to load authentication key '/var/run/pulse/.pulse-cookie': No such file>
Jul 31 13:57:09 ubuntu systemd[1]: Started pulseaudio.service - Pulse Audio.
Jul 31 14:01:57 ubuntu pulseaudio[686]: Denied access to client with invalid authentication data.
Jul 31 14:01:57 ubuntu pulseaudio[686]: Denied access to client with invalid authentication data.
Jul 31 14:04:13 ubuntu pulseaudio[686]: Denied access to client with invalid authentication data.
Jul 31 14:04:13 ubuntu pulseaudio[686]: Denied access to client with invalid authentication data.