[mythtv-users] systemd foo

James Linder jam at tigger.ws
Tue Jan 9 22:13:25 UTC 2024



> On Jan 9, 2024, at 19:54, Stephen Worthington <stephen_agent at jsw.gen.nz> wrote:
> 
> On Tue, 9 Jan 2024 15:19:18 +0800, you wrote:
> 
>> Giday All
>> 
>> I have an issue of mythbackend not starting on this hardware at boot. I have pummeled the service file until it works but for my edification (not a real word) is there a better way? I want to WAIT until /store (a usb ssh) is mounted (and on this hardware a hplug signal is not emmited at boot: I thought it was the distro, but it’s the hardware)
>> 
>> [Unit]
>> Description=MythTV backend service
>> After=network-online.target mysql.service
>> Requires=mysql.service
>> Wants=network-online.target
>> 
>> [Service]
>> Type=simple
>> EnvironmentFile=/etc/sysconfig/mythbackend.env
>> User=jam
>> Group=video
>> ExecStartPre=bash -c "for((i=1;i<=90;i+=1)); do if [ -b /dev/disk/by-label/MYTHTV ]; then break; fi; sleep 1; done"
>> ExecStart=/usr/local/bin/mythbackend --logpath /var/log/mythtv $MYTHBACKEND_OPTIONS
>> 
>> [Install]
>> WantedBy=multi-user.target
>> 
>> Thanks
>> James
> 
> Systemd allows you to wait for any mountpoint to be mounted, using the
> .mount units.  You translate the mountpoint path to the correct unit
> name like this:
> 
> Mountpoint: /mnt/rec1
> Becomes:    mnt-rec1.mount
> 
> So remove the initial / then change all further / characters to -
> characters, then add .mount.
> 
> Should your mountpoint path contain a - character, it should be
> replaced by \\x2d
> 
> Mountpoint: /mnt/crw-pvr
> Becomes:    mnt-crw\\x2dpvr.mount
> 
> So:
> 
> Mountpoint: /store
> Becomes:    store.mount
> 
> And in your mythbackend .service file, in the [Unit] section you would
> add:
> 
> Wants=store.mount
> After=store.mount
> 
> The .mount units can be automatically created (from fstab usually) or
> you can actually write a .mount systemd unit file for total control
> (not recommended).  See
> https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html
> 
> If you look under /run/systemd, you should find all the automatically
> created .mount files:
> 
> find /run/systemd/ -iname "*.mount"

Thanks

Multiple Wants on same line and enable again got it working. (many failed tries)

[Unit]
Description=MythTV backend service
Wants=store.mount dev-dvb-adapter0.mount dev-dvb-adapter3.mount
Requires=mysql.service
After=store.mount dev-dvb-adapter3.mount dev-dvb-adapter0.mount mysql.service

[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/mythbackend.env
User=jam
Group=video
ExecStart=/usr/local/bin/mythbackend --logpath /var/log/mythtv $MYTHBACKEND_OPTIONS

[Install]
WantedBy=multi-user.target

James



More information about the mythtv-users mailing list