Systemd unit file: Can/Should ExecStart and ExecStop run a script?

"J├│hann B. Gu├░mundsson" johannbg at gmail.com
Wed Oct 19 18:58:25 UTC 2011


On 10/19/2011 06:43 PM, Richard Shaw wrote:
> It looks like I'll be taking over mythtv packaging for RPM Fusion and
> I noticed it still only uses a sysv init script.
>
> In the sysv script it sets some ACL permissions on video and audio
> devices necessary for the backend service, and then on shutdown
> changes it back.
>
> I don't see any way to accomplish this in a systemd unit file other
> than running a script.
>
> What's the right way to do this? I have a template unit file (not
> meant to "work" yet):
>
> [Unit]
> Description=MythTV backend service
> After=mysqld.service
>
> [Service]
> Type=forking
> PIDFile=/var/run/mythbackend.pid
> ExecStart=/bin/sh /usr/libexec/mythtv/startmythbackend.sh
> ExecStop=/bin/sh /usr/libexec/mythtv/stopmythbackend.sh
>
> [Install]
> WantedBy=multi-user.target

This is what I wrote a while back for mythtv in rpmfusion but never 
submitted since I could not find someone to test it.

Note this got picked up by someone and adapted to atrpm version the 
other day.

Cant recall if that indvidual pinged me on irc or on some mailing list.

#cat mythbackend.service

[Unit]
Description=MythTV Backend
After=syslog.target network.target mysqld.service

[Service]
Type=forking
PIDFile=/run/mythbackend.pid
Environment=MYTHCONFDIR=/etc/mythtv
Environment=HOME=/etc/mythtv
ExecStart=/usr/bin/mythbackend --daemon --logfile 
/var/log/mythtv/mythbackend.log --pidfile /run/mythbackend.pid
StandardError=syslog

[Install]
WantedBy=multi-user.target


More information about the devel mailing list