]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/ventoy/hook/suse/udev_disk_hook.sh
1.1.07 release
[Ventoy.git] / IMG / cpio / ventoy / hook / suse / udev_disk_hook.sh
1 #!/ventoy/busybox/sh
2 #************************************************************************************
3 # Copyright (c) 2020, longpanda <admin@ventoy.net>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <http://www.gnu.org/licenses/>.
17 #
18 #************************************************************************************
19
20 . /ventoy/hook/ventoy-hook-lib.sh
21
22 ventoy_os_install_dmsetup() {
23 vtlog "ventoy_os_install_dmsetup $1"
24
25 vt_usb_disk=$1
26
27 # dump iso file location
28 $VTOY_PATH/tool/vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
29
30 # install dmsetup
31 LINE=$($GREP 'device-mapper-[0-9]\..*\.rpm' $VTOY_PATH/iso_file_list)
32 if [ $? -eq 0 ]; then
33 install_rpm_from_line "$LINE" ${vt_usb_disk}
34 fi
35
36 vtlog "dmsetup install finish, now check it..."
37
38 dmsetup_path=$(ventoy_find_bin_path dmsetup)
39 if [ -z "$dmsetup_path" ]; then
40 vterr "dmsetup still not found after install"
41 elif $dmsetup_path info >> $VTLOG 2>&1; then
42 vtlog "$dmsetup_path work ok"
43 else
44 vterr "$dmsetup_path not work"
45 fi
46 }
47
48 if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
49 exit 0
50 fi
51
52 dmsetup_path=$(ventoy_find_bin_path dmsetup)
53 if [ -z "$dmsetup_path" ]; then
54 ventoy_os_install_dmsetup "/dev/${1:0:-1}"
55 fi
56
57 if [ -f /proc/devices ]; then
58 vtlog "/proc/devices exist OK"
59 else
60 for i in 1 2 3 4 5 6 7 8 9; do
61 if [ -f /proc/devices ]; then
62 vtlog "/proc/devices exist OK now"
63 break
64 else
65 vtlog "/proc/devices NOT exist, wait $i"
66 $BUSYBOX_PATH/sleep 1
67 fi
68 done
69 fi
70
71
72 ventoy_udev_disk_common_hook $*
73
74 # OK finish
75 set_ventoy_hook_finish