You are not logged in.

#1 2012-10-20 18:06:53

jrussell
Member
From: Cape Town, South Africa
Registered: 2012-08-16
Posts: 510

systemd - help with creating a service file

Hi, I am trying to make a service file to execute "devmon --no-mount --exec-on-audio abcde". Basicly I want abcde to run when an audio cd is inserted into a headless computer. I have tried some udev rules but had no luck with that.

I then found udevil and devmon, and it seems to do exectly what I want.

So Ive made a systemd service file and put it in to /usr/lib/systemd/system

here is it:
/usr/lib/systemd/system/abcde-auto.service

[Unit]
Description=Virtual Distributed Ethernet

[Service]
Type=simple
ExecStart=/usr/bin/devmon --no-mount --exec-on-audio abcde


[Install]
WantedBy=multi-user.target

I have started this with

systemctl start abcde-auto.service

and I see that a devmon process has started with the same arguments I gave in the service file, so all is good.

But now, I am not too sure about the "Type" in the service file, devmon starts abcde, but:

systemctl stop abcde-auto.service

does not stop abcde, only devmon.

Is there a way to setup the service file so that abcde will end as well as devmon?

*Edit
Ive read this http://www.freedesktop.org/software/sys … rvice.html but Im still not too sure. Dont really know what most of it means.

Last edited by jrussell (2012-10-20 18:09:23)


bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U

Offline

#2 2012-10-20 18:10:46

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: systemd - help with creating a service file

I can't help you with service, but devmon should be started in .xinitrc or your startup script.

Offline

#3 2012-10-20 18:12:49

jrussell
Member
From: Cape Town, South Africa
Registered: 2012-08-16
Posts: 510

Re: systemd - help with creating a service file

Šaran wrote:

I can't help you with service, but devmon should be started in .xinitrc or your startup script.

no user logs on to the computer so .xinitrc wont help (I dont think?), what startup script are you refering to?


bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U

Offline

#4 2012-10-20 18:21:31

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: systemd - help with creating a service file

I'm sorry, I didn't see that headless part.
You could use ExecStop= to kill abcde.

Last edited by Šaran (2012-10-20 18:21:39)

Offline

#5 2012-10-22 08:40:12

jrussell
Member
From: Cape Town, South Africa
Registered: 2012-08-16
Posts: 510

Re: systemd - help with creating a service file

Šaran wrote:

I'm sorry, I didn't see that headless part.
You could use ExecStop= to kill abcde.

Ill give that a try, thanks


bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U

Offline

#6 2012-10-22 22:21:42

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: systemd - help with creating a service file

I use type 'oneshot' and add an ExecStop= to start and stop scripts.

Like here is the unit file I use to start and stop arno-iptables-firewall

[Unit]
Description=Arno iptables firewall

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/arno-iptables-firewall start
ExecStop=/usr/sbin/arno-iptables-firewall stop

[Install]
WantedBy=multi-user.target

OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#7 2013-11-08 10:33:54

roeleman
Member
Registered: 2007-11-09
Posts: 46

Re: systemd - help with creating a service file

Hello jrussel,

what did your service became then after all?  I'm busy with making a headless music server and want to do auto-ripping also when inserting an audio-cd.  It didn't work out also to use udev rules for that.

I want to go the udevil/devmon way.

Thanks in advance!

Offline

#8 2013-12-24 04:08:21

v43
Member
Registered: 2011-02-03
Posts: 140

Re: systemd - help with creating a service file

maybe there's a more elegant way, but this works:

ExecStop=/usr/bin/killall abcde

Offline

Board footer

Powered by FluxBB