You are not logged in.

#1 2014-01-17 17:08:15

Nattgew
Member
Registered: 2013-10-09
Posts: 30

Permissions for Running DarkIce

I am using DarkIce to send microphone input to Icecast. It works fine if I run it as a normal user. However, I would like to get either a systemd service or a cron job to run it. I can't get either one to work. The cron job has no error but doesn't work, and the systemd service gives "Connection refused". Here are the details:

Here is what it looks like when run as a normal user, and it works:

DarkIce 1.2 live audio streamer, [url]http://code.google.com/p/darkice/[/url]
Copyright (c) 2000-2007, Tyrell Hungary, [url]http://tyrell.hu/[/url]
Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz
This is free software, and you are welcome to redistribute it
under the terms of The GNU General Public License version 3 or
any later version.

Using config file: /etc/darkice.cfg
Using ALSA DSP input device: pulse
Using POSIX real-time scheduling, priority 0

I did a "crontab -e" as the normal user, adding the following:

*/1 * * * * darkice

I also tried making a job in /etc/cron.d

*/1 * * * * matt darkice

I also tried adding the "-c /etc/darkice.cfg" option to specify the config file. In all cases, it just outputs the "header" stuff but doesn't do anything, not even errors:

Jan 17 07:38:01 march crond[14190]: pam_unix(crond:session): session opened for user matt by (uid=0)
Jan 17 07:38:01 march crond[14192]: pam_unix(crond:session): session opened for user matt by (uid=0)
Jan 17 07:38:01 march CROND[14192]: (matt) CMDOUT (DarkIce 1.2 live audio streamer, [url]http://code.google.com/p/d[/url]
Jan 17 07:38:01 march CROND[14192]: (matt) CMDOUT (Copyright (c) 2000-2007, Tyrell Hungary, [url]http://tyrell.hu/)[/url]
Jan 17 07:38:01 march CROND[14192]: (matt) CMDOUT (Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz)
Jan 17 07:38:01 march CROND[14192]: (matt) CMDOUT (This is free software, and you are welcome to redistribute

I also tried setting up a systemd service file. I'm not trying to enable it at boot, I just want to get it working.

[Unit]
Description=Start Darkice source for Icecast
After=sound.target
Requires=icecast.service

[Service]
Type=forking
User=matt
Group=matt
WorkingDirectory=/tmp
ExecStart=/usr/bin/darkice -c /etc/darkice.cfg

This seems to get things further, in that there is at least an error to look at.

Jan 17 08:11:08 march darkice[14407]: under the terms of The GNU General Public License version 3 or
Jan 17 08:11:08 march darkice[14407]: any later version.
Jan 17 08:11:08 march darkice[14407]: Using config file: /etc/darkice.cfg
Jan 17 08:11:08 march darkice[14407]: Using ALSA DSP input device: pulse
Jan 17 08:11:08 march darkice[14407]: Using POSIX real-time scheduling, priority 0
Jan 17 08:11:08 march darkice[14407]: ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
Jan 17 08:11:08 march darkice[14407]: DarkIce: DarkIce.cpp:1273: can't open connector [0]
Jan 17 08:11:08 march systemd[1]: darkice.service: control process exited, code=exited status=255
Jan 17 08:11:08 march systemd[1]: Failed to start Start Darkice source for Icecast.
Jan 17 08:11:08 march systemd[1]: Unit darkice.service entered failed state.

If I am root, I get the same error if I run "sudo -u matt darkice", but "su matt -c darkice" works fine. This makes me suspect there is something going on with the way the command is run that I don't understand. If I run it as root, I get "Unable to connect: Access denied".
Here is the input section from darkice.cfg in case it matters:

[input]
device          = pulse  # OSS DSP soundcard device for the audio input
sampleRate      = 22050     # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample   = 16        # bits per sample. try 16
channel         = 1         # channels. 1 = mono, 2 = stereo

I figure this is more likely a problem with how cron/systemd are running DarkIce than a problem with PulseAudio permissions, since it does work when run normally. Anyone know more about these systems that could offer some insight?

Offline

#2 2014-01-17 18:09:21

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: Permissions for Running DarkIce

I'd debug the sudo line as that is the easiest to do. You could strace the call to see where it attempts to connect to? This might also be related to environment variables, does 'su -' fail too?

Offline

#3 2014-01-18 00:51:42

Nattgew
Member
Registered: 2013-10-09
Posts: 30

Re: Permissions for Running DarkIce

It turns out that "sudo -u matt darkice" works locally (xfce4-terminal) but not in ssh (where I was trying it). I did an strace of the failure in ssh, but not sure what to look for.
I ran "su - matt", and then DarkIce gives "Connection refused" so it seems related to the shell that runs it.

Offline

#4 2014-01-18 15:33:20

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: Permissions for Running DarkIce

Okay so does darkice start locally without x11 running? Then you might fix it reading http://unix.stackexchange.com/questions … en-display
If it doesn't try `strace -eopen darkice` over ssh (which doesn't work) and look at the path it opens; which results in 'Connection refused'.
You could also try ssh-ing to localhost; does that work? Because then you need to run `set` and determine which environment variable is used by alsa/pulse/darkice

Offline

Board footer

Powered by FluxBB