mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-11-30 17:36:19 +01:00
Add a cleanup service for Ventoy udev rules files
When we boot an ISO file to the live system through Ventoy. The ISO partition (e.g. /dev/sda1) is hold by the device-mapper which will block it to be mounted. So Ventoy will create a mirror device-mapper /dev/mapper/VentoyPart for /dev/sda1. Most live systems with GUI environment will auto mount Ventoy ISO partition by udisk. So in 1.1.18 Venoty will inject an udev rule in the Live system in order to: 1. Block the original ISO partition (e.g. /dev/sda1) to be auto-mounted. 2. Force /dev/mapper/VentoyPart to be auto-mounted. But the udev rule file was injected to /etc directory of the Live system, this will make the rule mistakenly inherited into the final installed system. Originally, the /run directory would have been the most suitable location, but in some Live systems /run is not a static directory but an overlayfs which is created dynamically during boot which make it a little bit complex. So we add a cleanup systemd/sysvinit service.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
set +e
|
||||
|
||||
rm -f /etc/boot.d/S01-ventoy-udev-trigger*
|
||||
rm -f /etc/runlevels/sysinit/ventoy-udev-trigger*
|
||||
rm -f /etc/runlevels/default/ventoy-udev-trigger*
|
||||
rm -f /etc/dinit.d/boot.d/ventoy-udev-trigger*
|
||||
rm -f /etc/dinit.d/default/ventoy-udev-trigger*
|
||||
rm -f /etc/runit/runsvdir/sysinit/ventoy-udev-trigger*
|
||||
rm -f /etc/runit/runsvdir/default/ventoy-udev-trigger*
|
||||
rm -f /etc/s6/adminsv/sysinit/contents.d/ventoy-udev-trigger*
|
||||
|
||||
rm -f /etc/init.d/ventoy-udev-trigger*
|
||||
rm -f /etc/dinit.d/ventoy-udev-trigger*
|
||||
rm -rf /etc/runit/sv/ventoy-udev-trigger*
|
||||
rm -rf /etc/s6/sv/ventoy-udev-trigger*
|
||||
|
||||
|
||||
if ls -l /etc/udev/rules.d/ | grep -q ventoy; then
|
||||
mkdir -p /run/udev/rules.d
|
||||
mv /etc/udev/rules.d/*ventoy* /run/udev/rules.d/
|
||||
fi
|
||||
|
||||
|
||||
if [ -f /etc/rc.local ]; then
|
||||
if grep -q ventoy /etc/rc.local; then
|
||||
sed -i '/ventoy/d' /etc/rc.local
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ -f /etc/s6/rc.local ]; then
|
||||
if grep -q ventoy /etc/s6/rc.local; then
|
||||
sed -i '/ventoy/d' /etc/s6/rc.local
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
setsid sh -c '
|
||||
count=0
|
||||
while [ $count -lt 60 ]; do
|
||||
if pidof udisksd >/dev/null 2>&1; then
|
||||
udevadm trigger --action=change --subsystem-match=block --sysname-match=yyy
|
||||
udevadm trigger --action=change --subsystem-match=block --sysname-match=DMXXX
|
||||
sleep 1
|
||||
break
|
||||
fi
|
||||
count=$((count + 1))
|
||||
sleep 2
|
||||
done
|
||||
' &
|
||||
|
||||
|
||||
rm -f $0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user