Re: Running VDR from systemd on Raspberry Pi OS

Marko Mäkelä <[email protected]> Tue, 27 Dec 2022 12:04:00 +0200
Newsgroups gmane.linux.vdr
Message-ID <Y6rDEOtmG/zKfQ7x@jyty>
Mon, Dec 26, 2022 at 01:34:48AM +0100, Udo Richter wrote:
>No, just replace the call to vdr in the service with a call to a runvdr
>script (any of the ones floating around, or just a three-liner), and in
>that script, after vdr ends, do whatever cleanup you need to do.

I see. That could certainly work.

I could execute "udisksctl unmount -f /dev/disk/by-label/VDR" to have 
the file system lazily unmounted as soon as all files are closed. But 
there is no such lazy option for power-off, and power-off itself will 
not unmount the file system.

Because I store the VDR configuration outside of this file system, it 
should be safe to attempt to unmount the video directory while VDR is 
running:

#!/bin/sh
set -e
if [ "$5" = 1 ]
then
   sudo udisksctl unmount -b /dev/disk/by-label/VDR
   sudo udisksctl power-off -b /dev/disk/by-label/VDR
   sudo service vdr stop
fi

I tested that the above script works when I press the Power button while 
watching live TV. If I am watching a recording that resides on this file 
system, the first command will fail, and thanks to "set -e", the rest of 
the script (in particular, shutting down the VDR service) will be 
skipped, that is, VDR will keep running.

In addition to having this script, I might configure some more, such as:

* Write some udev rule so that when the USB storage is unplugged and 
replugged, the file system will be auto-mounted and VDR service will be 
started.
* Restore /etc/systemd/logind.conf to HandlePowerKey=poweroff so that 
the system can be easily shut down by pressing the Power button again.

That would make it easy to do things like moving the disk to another 
computer for backing up or managing recordings. (Yes, I would rather use 
the native speed of the drive via USB 3, rather than have it throttled 
by 100 Mb/s Ethernet or the single USB 2.0 bus of the Raspberry Pi 2.)

In fact, this type of setup would also allow easy swapping of USB drives 
(one at a time) for making or watching recordings, a little like it was 
in the VCR times. The downtime for swapping drives would be a few 
seconds. The VDR configuration would be stored in the root file system, 
outside these detachable drives. The user interface to the entire setup 
would remain "living room compliant": remote control, display, and the 
USB cable of the drive.

The system could keep powering other tasks (such as home automation) 
while no storage is attached. If I didn't care about downtime, I might 
also use the following crude script to simply shut down the entire 
system:

#!/bin/sh
if [ "$5" = 1 ]
then
   sudo shutdown -h now
fi

In either case, the user would be responsible for starting VDR in time 
for the next scheduled recording.

	Marko

_______________________________________________
vdr mailing list
[email protected]
https://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr