Jul 01 16:47:17 server start.sh[21353]: Operation successfully completed
Jul 01 16:47:17 server start.sh[21353]: Saving 5 titles into directory ./raw
Jul 01 17:17:48 server start.sh[21353]: 5 titles saved
Jul 01 17:17:48 server start.sh[21353]: Copy complete. 5 titles saved.
Jul 01 17:17:48 server start.sh[21353]: title_t00.mkv
Jul 01 17:17:49 server start.sh[21353]: MOVIE
Jul 01 17:17:50 server systemd[1]: Started DVD-Ripper.
Jul 01 17:17:50 server start.sh[8906]: MakeMKV v1.14.4 linux(x64-release) started
Jul 01 17:17:52 server start.sh[8906]: Failed to open disc
Jul 01 17:17:52 server start.sh[8906]: Movie.mkv
Jul 01 17:17:52 server start.sh[8906]: rm: cannot remove '*.mkv': No such file or directory
即使我在 .service 文件中设置了 Restart=no,该服务仍会如图所示重新启动:
[Unit]
Description=DVD-Ripper
[Service]
ExecStart=/mnt/DVD/MakeMKV/start.sh
KillMode=mixed
SendSIGKILL=no
User=root
Restart=no
有谁知道为什么会发生这种情况?
这是来自使用journalctl -u DVD-Ripper 的日志
Jul 01 16:46:30 server start.sh[21353]: MakeMKV v1.14.4 linux(x64-release) started
Jul 01 16:46:33 server start.sh[21353]: Using direct disc access mode
Jul 01 16:46:39 server start.sh[21353]: Title #1 was added (25 cell(s), 0:47:07)
Jul 01 16:46:40 server start.sh[21353]: Title #1/0/1 was added (5 cell(s), 0:24:19)
Jul 01 16:46:41 server start.sh[21353]: Title #1/0/2 was added (5 cell(s), 0:24:18)
Jul 01 16:46:41 server start.sh[21353]: Title #2 was added (25 cell(s), 0:47:07)
Jul 01 16:46:41 server start.sh[21353]: Title #3 was added (5 cell(s), 0:24:19)
Jul 01 16:46:41 server start.sh[21353]: Title #4 was added (5 cell(s), 0:24:18)
Jul 01 16:47:08 server start.sh[21353]: Title #7 was added (5 cell(s), 0:04:59)
Jul 01 16:47:08 server start.sh[21353]: Title #8 was added (5 cell(s), 0:04:59)
Jul 01 16:47:08 server start.sh[21353]: Title #9 has length of 36 seconds which is less tha
Jul 01 16:47:08 server start.sh[21353]: Title #10 has length of 53 seconds which is less th
Jul 01 16:47:09 server start.sh[21353]: Title #11 has length of 26 seconds which is less th
Jul 01 16:47:09 server start.sh[21353]: Title #12 was added (1 cell(s), 0:02:22)
Jul 01 16:47:09 server start.sh[21353]: Title #13 has length of 99 seconds which is less th
Jul 01 16:47:09 server start.sh[21353]: Title #14 has length of 25 seconds which is less th
Jul 01 16:47:10 server start.sh[21353]: Title #15 has length of 111 seconds which is less t
Jul 01 16:47:10 server start.sh[21353]: Title #16 has length of 62 seconds which is less th
Jul 01 16:47:10 server start.sh[21353]: Title #17 has length of 33 seconds which is less th
Jul 01 16:47:10 server start.sh[21353]: Title 1 in VTS 3 is equal to title 4 and was skippe
Jul 01 16:47:11 server start.sh[21353]: Title 2 in VTS 3 is equal to title 4 and was skippe
Jul 01 16:47:11 server start.sh[21353]: Title 3 in VTS 3 is equal to title 4 and was skippe
Jul 01 16:47:11 server start.sh[21353]: Title 4 in VTS 5 is equal to title 3 and was skippe
Jul 01 16:47:17 server start.sh[21353]: Operation successfully completed
Jul 01 16:47:17 server start.sh[21353]: Saving 5 titles into directory ./raw
Jul 01 17:17:48 server start.sh[21353]: 5 titles saved
Jul 01 17:17:48 server start.sh[21353]: Copy complete. 5 titles saved.
Jul 01 17:17:48 server start.sh[21353]: title_t00.mkv
Jul 01 17:17:49 server start.sh[21353]: MOVIE
Jul 01 17:17:50 server systemd[1]: Started DVD-Ripper.
Jul 01 17:17:50 server start.sh[8906]: MakeMKV v1.14.4 linux(x64-release) started
Jul 01 17:17:52 server start.sh[8906]: Failed to open disc
Jul 01 17:17:52 server start.sh[8906]: MOVIE.mkv
Jul 01 17:17:52 server start.sh[8906]: rm: cannot remove '*.mkv': No such file or directory
这是文件中的 ExecStart:
#!/bin/bash
cd /mnt/DVD/MakeMKV/
makemkvcon mkv disc:0 all ./raw
cd ./raw
file=$(ls -S | head -1)
echo $file
mv "$file" ./final
rm *.mkv
mv ./final/* ./
DVD_NAME=$(udevadm info -n sr1 -q property | sed -n 's/^ID_FS_LABEL=//p')
echo $DVD_NAME
mv ./*.mkv ./$DVD_NAME.mkv
eject sr1
这是触发器:
KERNEL=="sr1", ACTION=="change",ENV{ID_CDROM_MEDIA_DVD}="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/mnt/DVD/MakeMKV/trigger.sh"
触发器.sh包含:
systemctl start DVD-Ripper
编辑- UDEV 触发器在插入和移除时都会触发。如何修改触发器以仅检查 DVD 插入?
答案1
谢谢您的帮助。我最终通过修改我的trigger.sh 文件来解决这个问题,并让 udev 触发器保持不变。这是trigger.sh 中的内容:
#!/bin/bash
cd /mnt/DVD/MakeMKV/
info=$(blkid -o value -s TYPE /dev/sr1)
type=$(echo 'udf')
echo $info
echo $type
if [ "$info" == "$type" ]
then
systemctl start DVD-Ripper
fi
它检查类型并检查它是否是 udf。如果没有插入 DVD,$info 返回空白,插入时等于“udf”,因此插入时,它使 if 语句为 true。
谢谢您的帮助!
答案2
Udev 允许您对硬件事件做出反应,在本例中ACTION
可以是add
, remove
, change
。
ACTION=="change"
当插入或弹出 DVD 时,它将触发。
尝试以下规则:
KERNEL=="sr1", ACTION=="add",ENV{ID_CDROM_MEDIA_DVD}="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/mnt/DVD/MakeMKV/trigger.sh"