]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - IMG/cpio/ventoy/hook/rhel5/ventoy-loader.sh
1.0.95 release
[Ventoy.git] / IMG / cpio / ventoy / hook / rhel5 / ventoy-loader.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 'minstg2.img' $VTOY_PATH/iso_file_list)
32 if [ $? -eq 0 ]; then
33 extract_file_from_line "$LINE" ${vt_usb_disk} /tmp/minstg2.img
34
35 mkdir -p /tmp/ramfs/minstg2.img
36 mount -t squashfs /tmp/minstg2.img /tmp/ramfs/minstg2.img
37
38 $BUSYBOX_PATH/ln -s /tmp/ramfs/minstg2.img/lib64 /lib64
39 $BUSYBOX_PATH/ln -s /tmp/ramfs/minstg2.img/usr /usr
40 fi
41
42 vtlog "dmsetup install finish, now check it..."
43
44 dmsetup_path=$(ventoy_find_bin_path dmsetup)
45 if [ -z "$dmsetup_path" ]; then
46 vterr "dmsetup still not found after install"
47 elif $dmsetup_path info >> $VTLOG 2>&1; then
48 vtlog "$dmsetup_path work ok"
49 else
50 vterr "$dmsetup_path not work"
51 fi
52 }
53
54 vtlog "##### $0 $* ########"
55
56 vtdiskname=$(get_ventoy_disk_name)
57
58 dmsetup_path=$(ventoy_find_bin_path dmsetup)
59 if [ -z "$dmsetup_path" ]; then
60 ventoy_os_install_dmsetup "$vtdiskname"
61 ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
62
63 $BUSYBOX_PATH/unlink /lib64
64 $BUSYBOX_PATH/unlink /usr
65 umount /tmp/ramfs/minstg2.img
66 rm -rf /tmp/ramfs/minstg2.img
67 rm -f /tmp/minstg2.img
68 else
69 ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
70 fi