[mythtv-users] systemd foo

Stephen Worthington stephen_agent at jsw.gen.nz
Tue Jan 9 11:54:17 UTC 2024


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"


More information about the mythtv-users mailing list