libldm icon indicating copy to clipboard operation
libldm copied to clipboard

systemd unit

Open rathann opened this issue 4 years ago • 13 comments

Would you consider adding a simple systemd unit, e.g.:

[Unit]
Description=Activate Windows Logical Disk Manager volumes
Documentation=man:ldmtool(1)

[Service]
ExecStart=/usr/bin/ldmtool create all
ExecStop=/usr/bin/ldmtool remove all
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

This would allow adding LDM mounts to fstab, e.g.:

/dev/mapper/ldm_vol_LOCALHOST-Dg0_Volume1 /mnt/windata ntfs defaults,rw,x-systemd.requires=ldm.service 0 0

rathann avatar Mar 22 '21 09:03 rathann

I guess so. I tried to use autoconf to substitute the correct @bindir@ but it insists on putting ${exec_prefix} into the path for spurious reasons. Do you have a suggested patch?

rwmjones avatar Mar 22 '21 10:03 rwmjones

No patch, sorry. But if you post your not-exactly-working one, I could take a look and maybe fix it.

rathann avatar Mar 22 '21 14:03 rathann

Sure, it's completely wrong though: http://oirase.annexia.org/tmp/0001-Add-example-systemd-unit-file.patch.txt

rwmjones avatar Mar 22 '21 15:03 rwmjones

Not sure what you mean by completely wrong, it works just fine for me. The unit file generated by configure has /usr/bin/ldmtool in it.

rathann avatar Mar 23 '21 11:03 rathann

For me it has:

[Service]
ExecStart=${exec_prefix}/bin/ldmtool create all
ExecStop=${exec_prefix}/bin/ldmtool remove all

rwmjones avatar Mar 23 '21 13:03 rwmjones

Which distro? I was testing on F33.

rathann avatar Mar 23 '21 21:03 rathann

Even on rawhide, the resulting unit file contains /usr/bin/ldmtool. I did both tests in mock, so I'm not sure why you're seeing different results.

rathann avatar Mar 24 '21 08:03 rathann

Here's my patch for Fedora package that I used for testing: 0001-New-upstream-version-0.2.5.patch.txt

rathann avatar Mar 24 '21 08:03 rathann

It still has ${exec_prefix} for me (when compiling from source). This is a well-known misfeature of autoconf: https://stackoverflow.com/questions/54405359/how-to-recursively-substitute-variable-for-a-path-in-bash-variable-in-configure

I wonder if either make install or RPM are fixing it?

rwmjones avatar Mar 24 '21 10:03 rwmjones

So it's make install. I'll add my patch since it should be ok after all.

rwmjones avatar Mar 24 '21 10:03 rwmjones

I pushed this: https://github.com/mdbooth/libldm/commit/5014da5b90713123157b2604ac566514682e7f37

The Makefile.am probably needs adjusting further to install this file in some place, although maybe we don't want to install this for everyone, just "suggest" it.

rwmjones avatar Mar 24 '21 10:03 rwmjones

So it's make install. I'll add my patch since it should be ok after all.

Interesting. I haven't actually checked the contents between %build and %install, so I haven't seen this.

I pushed this: 5014da5

Thanks!

The Makefile.am probably needs adjusting further to install this file in some place, although maybe we don't want to install this for everyone, just "suggest" it.

I think it's fine to leave it in the source tree and let distros consume it at will for now.

rathann avatar Mar 24 '21 11:03 rathann

It might be even better to change WantedBy= from multi-user.target to local-fs-pre.target. This way the filesystems can be used in /etc/fstab even without specifying x-systemd.requires=ldm.service. If changed make sure to also add Before=local-fs-pre.target, so local-fs-pre.target isn't considered active until ldm.service is.

They're currently doing it this way on Arch Linux: https://github.com/archlinux/svntogit-community/blob/a7db3683d17aca7891a69110d9e6e2af9cea0544/trunk/ldmtool.service

jkhsjdhjs avatar Jan 25 '22 23:01 jkhsjdhjs