mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-08-28 00:11:15 +00:00
initial commit
This commit is contained in:
71
IMG/cpio/ventoy/hook/alpine/udev_disk_hook.sh
Normal file
71
IMG/cpio/ventoy/hook/alpine/udev_disk_hook.sh
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if [ "$SUBSYSTEM" != "block" ] || [ "$DEVTYPE" != "partition" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -b /dev/${MDEV:0:-1} ]; then
|
||||
vtlog "/dev/${MDEV:0:-1} exist"
|
||||
else
|
||||
$SLEEP 2
|
||||
fi
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${MDEV:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
#
|
||||
# longpanda:
|
||||
# Alpine initramfs doesn't contain dm-mod or fuse module,
|
||||
# and even the worse, the libpthread.so is not included too.
|
||||
# So here we directly dump the modloop squashfs file from disk to rootfs.
|
||||
# Fortunately, this file is not too big (< 100MB in alpine 3.11.3).
|
||||
# After that:
|
||||
# 1. mount the squashfs file
|
||||
# 2. find the dm-mod module from the mountpoint and insmod
|
||||
# 3. unmount and delete the squashfs file
|
||||
#
|
||||
|
||||
vtoydm -i -f $VTOY_PATH/ventoy_image_map -d /dev/${MDEV:0:-1} > $VTOY_PATH/iso_file_list
|
||||
|
||||
vtLine=$(grep '[-][-] modloop-lts ' $VTOY_PATH/iso_file_list)
|
||||
sector=$(echo $vtLine | awk '{print $(NF-1)}')
|
||||
length=$(echo $vtLine | awk '{print $NF}')
|
||||
|
||||
vtoydm -e -f $VTOY_PATH/ventoy_image_map -d /dev/${MDEV:0:-1} -s $sector -l $length -o /vt_modloop
|
||||
|
||||
mkdir -p $VTOY_PATH/mnt
|
||||
mount /vt_modloop $VTOY_PATH/mnt
|
||||
|
||||
KoModPath=$(find $VTOY_PATH/mnt/ -name 'dm-mod.ko*')
|
||||
vtlog "insmod $KoModPath"
|
||||
insmod $KoModPath
|
||||
|
||||
umount $VTOY_PATH/mnt
|
||||
rm -f /vt_modloop
|
||||
|
||||
ventoy_udev_disk_common_hook "$MDEV" "noreplace"
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
24
IMG/cpio/ventoy/hook/alpine/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/alpine/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
echo "-[-a-z0-9]*2 root:root 0666 @$BUSYBOX_PATH/sh $VTOY_PATH/hook/alpine/udev_disk_hook.sh" >> /mdev.conf
|
||||
$CAT /etc/mdev.conf >> /mdev.conf
|
||||
$BUSYBOX_PATH/mv /mdev.conf /etc/mdev.conf
|
34
IMG/cpio/ventoy/hook/arch/ventoy-hook.sh
Normal file
34
IMG/cpio/ventoy/hook/arch/ventoy-hook.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
# some archlinux initramfs doesn't contain device-mapper udev rules file
|
||||
ARCH_UDEV_DIR=$(ventoy_get_udev_conf_dir)
|
||||
if [ -s "$ARCH_UDEV_DIR/13-dm-disk.rules" ]; then
|
||||
echo 'dm-disk rule exist' >> $VTLOG
|
||||
else
|
||||
echo 'Copy dm-disk rule file' >> $VTLOG
|
||||
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$ARCH_UDEV_DIR/13-dm-disk.rules"
|
||||
fi
|
||||
|
||||
# use default proc
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
117
IMG/cpio/ventoy/hook/debian/antix-disk.sh
Normal file
117
IMG/cpio/ventoy/hook/debian/antix-disk.sh
Normal file
@@ -0,0 +1,117 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
|
||||
ventoy_os_install_dmsetup_by_unsquashfs() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_unsquashfs $*"
|
||||
|
||||
vtKoPo=$(ventoy_get_module_postfix)
|
||||
vtlog "vtKoPo=$vtKoPo"
|
||||
|
||||
vtoydm -i -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/iso_file_list
|
||||
|
||||
vtline=$(grep '[-][-] linuxfs ' $VTOY_PATH/iso_file_list)
|
||||
sector=$(echo $vtline | awk '{print $(NF-1)}')
|
||||
length=$(echo $vtline | awk '{print $NF}')
|
||||
|
||||
vtoydm -E -f $VTOY_PATH/ventoy_image_map -d $1 -s $sector -l $length -o $VTOY_PATH/fsdisk
|
||||
|
||||
dmModPath="/usr/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo"
|
||||
echo $dmModPath > $VTOY_PATH/fsextract
|
||||
vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk
|
||||
|
||||
if ! [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
|
||||
dmModPath="/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo"
|
||||
echo $dmModPath > $VTOY_PATH/fsextract
|
||||
vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk
|
||||
fi
|
||||
|
||||
if [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
|
||||
vtlog "success $VTOY_PATH/sqfs${dmModPath}"
|
||||
insmod $VTOY_PATH/sqfs${dmModPath}
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
ventoy_os_install_dmsetup_by_fuse() {
|
||||
vtlog "ventoy_os_install_dmsetup_by_fuse $*"
|
||||
|
||||
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso $VTOY_PATH/mnt/squashfs
|
||||
|
||||
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
|
||||
|
||||
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||
mount -t squashfs $VTOY_PATH/mnt/iso/antiX/linuxfs $VTOY_PATH/mnt/squashfs
|
||||
|
||||
KoName=$(ls $VTOY_PATH/mnt/squashfs/lib/modules/$2/kernel/drivers/md/dm-mod.ko*)
|
||||
vtlog "insmod $KoName"
|
||||
insmod $KoName
|
||||
|
||||
umount $VTOY_PATH/mnt/squashfs
|
||||
umount $VTOY_PATH/mnt/iso
|
||||
umount $VTOY_PATH/mnt/fuse
|
||||
}
|
||||
|
||||
|
||||
ventoy_os_install_dmsetup() {
|
||||
vtlog "ventoy_os_install_dmsetup"
|
||||
|
||||
if grep -q 'device-mapper' /proc/devices; then
|
||||
vtlog "device-mapper module already loaded"
|
||||
return;
|
||||
fi
|
||||
|
||||
vtKerVer=$(uname -r)
|
||||
|
||||
if ventoy_os_install_dmsetup_by_unsquashfs $1 $vtKerVer; then
|
||||
vtlog "unsquashfs success"
|
||||
else
|
||||
if modprobe fuse 2>>$VTLOG; then
|
||||
ventoy_os_install_dmsetup_by_fuse $1 $vtKerVer
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_os_install_dmsetup $vtdiskname
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
if ! [ -e $VTOY_DM_PATH ]; then
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
mknod -m 0666 $VTOY_DM_PATH b $blkdev_num
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
29
IMG/cpio/ventoy/hook/debian/antix-hook.sh
Normal file
29
IMG/cpio/ventoy/hook/debian/antix-hook.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
if $GREP -q 'FILTERED_LIST=[^a-zA-Z0-9_]*$' /init; then
|
||||
$SED 's#FILTERED_LIST=[^a-zA-Z0-9_]*$#FILTERED_LIST=/dev/mapper/ventoy#' -i /init
|
||||
elif $GREP -q '\[ "$FILTERED_LIST" \]' /init; then
|
||||
$SED '/\[ "$FILTERED_LIST" \]/i\ FILTERED_LIST="/dev/mapper/ventoy $FILTERED_LIST"' -i /init
|
||||
fi
|
||||
|
||||
$SED -i "/_search_for_boot_device_/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/antix-disk.sh" /init
|
||||
|
||||
# for debug
|
||||
#$SED -i "/^linuxfs_error/a\exec $VTOY_PATH/busybox/sh" /init
|
21
IMG/cpio/ventoy/hook/debian/default-hook.sh
Normal file
21
IMG/cpio/ventoy/hook/debian/default-hook.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
|
111
IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh
Normal file
111
IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
ventoy_os_install_dmsetup() {
|
||||
|
||||
vt_usb_disk=$1
|
||||
|
||||
# dump iso file location
|
||||
$VTOY_PATH/tool/vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
|
||||
|
||||
# install dmsetup
|
||||
LINE=$($GREP ' dmsetup.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
install_udeb_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
|
||||
# install libdevmapper
|
||||
LINE=$($GREP ' libdevmapper.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
install_udeb_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
|
||||
# install md-modules
|
||||
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
install_udeb_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
|
||||
# insmod md-mod if needed
|
||||
if $GREP -q 'device-mapper' /proc/devices; then
|
||||
vtlog "device mapper module is loaded"
|
||||
else
|
||||
vtlog"device mapper module is NOT loaded, now load it..."
|
||||
|
||||
VER=$($BUSYBOX_PATH/uname -r)
|
||||
KO=$($FIND /lib/modules/$VER/kernel/drivers/md -name "dm-mod*")
|
||||
vtlog "KO=$KO"
|
||||
|
||||
insmod $KO
|
||||
fi
|
||||
|
||||
vtlog "dmsetup install finish, now check it..."
|
||||
if dmsetup info >> $VTLOG 2>&1; then
|
||||
vtlog "dmsetup work ok"
|
||||
else
|
||||
vtlog "dmsetup not work, now try to load eglibc ..."
|
||||
|
||||
# install eglibc (some ubuntu 32 bit version need it)
|
||||
LINE=$($GREP 'libc6-.*\.udeb' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
install_udeb_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
|
||||
if dmsetup info >> $VTLOG 2>&1; then
|
||||
vtlog "dmsetup work ok after retry"
|
||||
else
|
||||
vtlog "dmsetup still not work after retry"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
dmsetup_path=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
#
|
||||
# Some distro default only accept usb partitions as install medium.
|
||||
# So if ventoy is installed on a non-USB device, we just mount /cdrom here except
|
||||
# for these has boot=live or boot=casper parameter in cmdline
|
||||
#
|
||||
if echo $ID_BUS | $GREP -q -i usb; then
|
||||
vtlog "$1 is USB device"
|
||||
else
|
||||
vtlog "$1 is NOT USB device (bus $ID_BUS)"
|
||||
|
||||
if $EGREP -q 'boot=|casper' /proc/cmdline; then
|
||||
vtlog "boot=, or casper, don't mount"
|
||||
else
|
||||
vtlog "No boot param, need to mount"
|
||||
$BUSYBOX_PATH/mkdir /cdrom
|
||||
$BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH /cdrom
|
||||
fi
|
||||
fi
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
31
IMG/cpio/ventoy/hook/debian/ventoy-hook.sh
Normal file
31
IMG/cpio/ventoy/hook/debian/ventoy-hook.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
DISTRO='default'
|
||||
|
||||
if [ -e /etc/initrd-release ]; then
|
||||
if $EGREP -q "ID=.*antix|ID=.*mx" /etc/initrd-release; then
|
||||
DISTRO='antix'
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "##### distribution = $DISTRO ######" >> $VTLOG
|
||||
. $VTOY_PATH/hook/debian/${DISTRO}-hook.sh
|
42
IMG/cpio/ventoy/hook/default/13-dm-disk.rules
Normal file
42
IMG/cpio/ventoy/hook/default/13-dm-disk.rules
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
|
||||
# Udev rules for device-mapper devices.
|
||||
#
|
||||
# These rules create symlinks in /dev/disk directory.
|
||||
# Symlinks that depend on probing filesystem type,
|
||||
# label and uuid are created only if the device is not
|
||||
# suspended.
|
||||
|
||||
# "add" event is processed on coldplug only!
|
||||
ACTION!="add|change", GOTO="dm_end"
|
||||
ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_end"
|
||||
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
|
||||
|
||||
SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
|
||||
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
|
||||
|
||||
ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
|
||||
ENV{DM_NOSCAN}=="1", GOTO="dm_watch"
|
||||
|
||||
IMPORT{builtin}="blkid"
|
||||
ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100"
|
||||
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
|
||||
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
|
||||
ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
|
||||
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
|
||||
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_GPT_AUTO_ROOT}=="1", SYMLINK+="gpt-auto-root"
|
||||
|
||||
# Add inotify watch to track changes on this device.
|
||||
# Using the watch rule is not optimal - it generates a lot of spurious
|
||||
# and useless events whenever the device opened for read-write is closed.
|
||||
# The best would be to generete the event directly in the tool changing
|
||||
# relevant information so only relevant events will be processed
|
||||
# (like creating a filesystem, changing filesystem label etc.).
|
||||
#
|
||||
# But let's use this until we have something better...
|
||||
LABEL="dm_watch"
|
||||
OPTIONS+="watch"
|
||||
|
||||
LABEL="dm_end"
|
30
IMG/cpio/ventoy/hook/default/udev_disk_hook.sh
Normal file
30
IMG/cpio/ventoy/hook/default/udev_disk_hook.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
24
IMG/cpio/ventoy/hook/default/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/default/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
36
IMG/cpio/ventoy/hook/gentoo/disk_hook.sh
Normal file
36
IMG/cpio/ventoy/hook/gentoo/disk_hook.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
# Just for KVM test enviroment
|
||||
$BUSYBOX_PATH/modprobe virtio_blk 2>/dev/null
|
||||
$BUSYBOX_PATH/modprobe virtio_pci 2>/dev/null
|
||||
|
||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "wait for disk ..."
|
||||
$SLEEP 2
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
27
IMG/cpio/ventoy/hook/gentoo/ventoy-hook.sh
Normal file
27
IMG/cpio/ventoy/hook/gentoo/ventoy-hook.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
if [ -d /etc/udev/rules.d ]; then
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
|
||||
else
|
||||
$SED "/mdev *-s/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init
|
||||
fi
|
39
IMG/cpio/ventoy/hook/kaos/udev_disk_hook.sh
Normal file
39
IMG/cpio/ventoy/hook/kaos/udev_disk_hook.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
modprobe fuse
|
||||
mkdir -p $VTOY_PATH/mnt/fuse $VTOY_PATH/mnt/iso
|
||||
|
||||
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d "/dev/${1:0:-1}" > $VTOY_PATH/ventoy_dm_table
|
||||
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m $VTOY_PATH/mnt/fuse
|
||||
mount -t iso9660 $VTOY_PATH/mnt/fuse/ventoy.iso $VTOY_PATH/mnt/iso
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
6
IMG/cpio/ventoy/hook/kaos/ventoy-hook.sh
Normal file
6
IMG/cpio/ventoy/hook/kaos/ventoy-hook.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/ventoy/busybox/sh
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/kaos/udev_disk_hook.sh %k"
|
40
IMG/cpio/ventoy/hook/mageia/udev_disk_hook.sh
Normal file
40
IMG/cpio/ventoy/hook/mageia/udev_disk_hook.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
#
|
||||
# cheatcode for mageia
|
||||
#
|
||||
# From mageia/soft/drakx/mdk-stage1 source code, we see that the stage1 binary will search
|
||||
# /tmp/syslog file to determin whether there is a DAC960 cdrom in the system.
|
||||
# So we insert some string to /tmp/syslog file to cheat the stage1 program.
|
||||
#
|
||||
$BUSYBOX_PATH/mkdir -p /dev/rd
|
||||
ventoy_copy_device_mapper "/dev/rd/ventoy"
|
||||
echo 'ventoy cheatcode /dev/rd/ventoy: model' >> /tmp/syslog
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
7
IMG/cpio/ventoy/hook/mageia/ventoy-hook.sh
Normal file
7
IMG/cpio/ventoy/hook/mageia/ventoy-hook.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/ventoy/busybox/sh
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/mageia/udev_disk_hook.sh %k noreplace"
|
33
IMG/cpio/ventoy/hook/manjaro/ventoy-hook.sh
Normal file
33
IMG/cpio/ventoy/hook/manjaro/ventoy-hook.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
# some distro initramfs doesn't contain device-mapper udev rules file
|
||||
DISTRO_UDEV_DIR=$(ventoy_get_udev_conf_dir)
|
||||
if [ -s "$DISTRO_UDEV_DIR/13-dm-disk.rules" ]; then
|
||||
echo 'dm-disk rule exist' >> $VTLOG
|
||||
else
|
||||
echo 'Copy dm-disk rule file' >> $VTLOG
|
||||
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$DISTRO_UDEV_DIR/13-dm-disk.rules"
|
||||
fi
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
30
IMG/cpio/ventoy/hook/nixos/udev_disk_hook.sh
Normal file
30
IMG/cpio/ventoy/hook/nixos/udev_disk_hook.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
25
IMG/cpio/ventoy/hook/nixos/ventoy-hook.sh
Normal file
25
IMG/cpio/ventoy/hook/nixos/ventoy-hook.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
vtRuleFile=$($FIND / -name '*.rules' -type f | $GREP udev | $HEAD -n1)
|
||||
|
||||
ventoy_add_udev_rule_with_path "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace" "${vtRuleFile%/*}/99-ventoy.rules"
|
||||
|
72
IMG/cpio/ventoy/hook/pclos/disk_hook.sh
Normal file
72
IMG/cpio/ventoy/hook/pclos/disk_hook.sh
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
ventoy_os_install_device_mapper_by_unsquashfs() {
|
||||
vtlog "ventoy_os_install_device_mapper_by_unsquashfs $*"
|
||||
|
||||
vtKoExt=$(ventoy_get_module_postfix)
|
||||
vtlog "vtKoExt=$vtKoExt"
|
||||
|
||||
vtoydm -i -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/iso_file_list
|
||||
|
||||
vtline=$(grep '[-][-] livecd.sqfs ' $VTOY_PATH/iso_file_list)
|
||||
sector=$(echo $vtline | awk '{print $(NF-1)}')
|
||||
length=$(echo $vtline | awk '{print $NF}')
|
||||
|
||||
vtoydm -E -f $VTOY_PATH/ventoy_image_map -d $1 -s $sector -l $length -o $VTOY_PATH/fsdisk
|
||||
|
||||
dmModPath="/lib/modules/$2/kernel/drivers/md/dm-mod.$vtKoExt"
|
||||
echo $dmModPath > $VTOY_PATH/fsextract
|
||||
vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk
|
||||
|
||||
if [ -e $VTOY_PATH/sqfs${dmModPath} ]; then
|
||||
vtlog "success $VTOY_PATH/sqfs${dmModPath}"
|
||||
insmod $VTOY_PATH/sqfs${dmModPath}
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
ventoy_os_install_device_mapper() {
|
||||
vtlog "ventoy_os_install_device_mapper"
|
||||
|
||||
if grep -q 'device-mapper' /proc/devices; then
|
||||
vtlog "device-mapper module already loaded"
|
||||
return;
|
||||
fi
|
||||
|
||||
vtKerVer=$(uname -r)
|
||||
if ventoy_os_install_device_mapper_by_unsquashfs $1 $vtKerVer; then
|
||||
vtlog "unsquashfs success"
|
||||
else
|
||||
vterr "unsquashfs failed"
|
||||
fi
|
||||
}
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
ventoy_os_install_device_mapper $vtdiskname
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
||||
PATH=$VTPATH_OLD
|
57
IMG/cpio/ventoy/hook/pclos/ventoy-hook.sh
Normal file
57
IMG/cpio/ventoy/hook/pclos/ventoy-hook.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
# Step 1: dd initrd file to ramdisk
|
||||
vtRamdiskFile=$($BUSYBOX_PATH/ls /initrd* | $HEAD -n1)
|
||||
$BUSYBOX_PATH/mknod -m 0666 /ram0 b 1 0
|
||||
$BUSYBOX_PATH/dd if=$vtRamdiskFile of=/ram0 status=none
|
||||
$BUSYBOX_PATH/rm -f $vtRamdiskFile
|
||||
|
||||
# Step 2: mount ramdisk
|
||||
$BUSYBOX_PATH/mkdir -p /ventoy_rdroot
|
||||
ventoy_close_printk
|
||||
$BUSYBOX_PATH/mount /ram0 /ventoy_rdroot
|
||||
ventoy_restore_printk
|
||||
|
||||
# Step 3: Copy ventoy tool to new root directory.
|
||||
# Here we make a tmpfs mount to avoid ramdisk out of space (additional space is for log).
|
||||
vtSize=$($BUSYBOX_PATH/du -m -s $VTOY_PATH | $BUSYBOX_PATH/awk '{print $1}')
|
||||
let vtSize=vtSize+4
|
||||
|
||||
$BUSYBOX_PATH/mkdir -p /ventoy_rdroot/ventoy
|
||||
$BUSYBOX_PATH/mount -t tmpfs -o size=${vtSize}m tmpfs /ventoy_rdroot/ventoy
|
||||
$BUSYBOX_PATH/cp -a /ventoy/* /ventoy_rdroot/ventoy/
|
||||
|
||||
|
||||
# Step 4: add hook in linuxrc&rc.sysinit script file
|
||||
vtLine=$($GREP -n "^find_cdrom" /ventoy_rdroot/linuxrc | $GREP -v '(' | $AWK -F: '{print $1}')
|
||||
$SED "$vtLine aif test -d /ventoy; then $BUSYBOX_PATH/sh $VTOY_PATH/hook/pclos/disk_hook.sh; fi" -i /ventoy_rdroot/linuxrc
|
||||
$SED "$vtLine aif test -d /initrd/ventoy; then ln -s /initrd/ventoy /ventoy; fi" -i /ventoy_rdroot/linuxrc
|
||||
|
||||
|
||||
vtRcInit=$($BUSYBOX_PATH/tail /ventoy_rdroot/linuxrc | $GREP 'exec ' | $AWK '{print $2}')
|
||||
if [ -e /ventoy_rdroot$vtRcInit ]; then
|
||||
vtRcInit=/ventoy_rdroot$vtRcInit
|
||||
else
|
||||
vtRcInit=/ventoy_rdroot/etc/rc.d/rc.sysinit
|
||||
fi
|
||||
|
||||
echo 'exec /sbin/init' >> $vtRcInit
|
23
IMG/cpio/ventoy/hook/rhel5/ventoy-hook.sh
Normal file
23
IMG/cpio/ventoy/hook/rhel5/ventoy-hook.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
#if [ -e $VTOY_PATH/hook/rhel5/loader ]; then
|
||||
# $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel5/loader /sbin/loader
|
||||
#fi
|
||||
#$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel5/ventoy-loader.sh $VTOY_PATH/tool/
|
70
IMG/cpio/ventoy/hook/rhel5/ventoy-loader.sh
Normal file
70
IMG/cpio/ventoy/hook/rhel5/ventoy-loader.sh
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
ventoy_os_install_dmsetup() {
|
||||
vtlog "ventoy_os_install_dmsetup $1"
|
||||
|
||||
vt_usb_disk=$1
|
||||
|
||||
# dump iso file location
|
||||
$VTOY_PATH/tool/vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
|
||||
|
||||
# install dmsetup
|
||||
LINE=$($GREP 'minstg2.img' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
extract_file_from_line "$LINE" ${vt_usb_disk} /tmp/minstg2.img
|
||||
|
||||
mkdir -p /tmp/ramfs/minstg2.img
|
||||
mount -t squashfs /tmp/minstg2.img /tmp/ramfs/minstg2.img
|
||||
|
||||
$BUSYBOX_PATH/ln -s /tmp/ramfs/minstg2.img/lib64 /lib64
|
||||
$BUSYBOX_PATH/ln -s /tmp/ramfs/minstg2.img/usr /usr
|
||||
fi
|
||||
|
||||
vtlog "dmsetup install finish, now check it..."
|
||||
|
||||
dmsetup_path=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
vterr "dmsetup still not found after install"
|
||||
elif $dmsetup_path info >> $VTLOG 2>&1; then
|
||||
vtlog "$dmsetup_path work ok"
|
||||
else
|
||||
vterr "$dmsetup_path not work"
|
||||
fi
|
||||
}
|
||||
|
||||
vtlog "##### $0 $* ########"
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
|
||||
dmsetup_path=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
ventoy_os_install_dmsetup "$vtdiskname"
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
$BUSYBOX_PATH/unlink /lib64
|
||||
$BUSYBOX_PATH/unlink /usr
|
||||
umount /tmp/ramfs/minstg2.img
|
||||
rm -rf /tmp/ramfs/minstg2.img
|
||||
rm -f /tmp/minstg2.img
|
||||
else
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
fi
|
20
IMG/cpio/ventoy/hook/rhel6/anaconda-repo-listen.sh
Normal file
20
IMG/cpio/ventoy/hook/rhel6/anaconda-repo-listen.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
sed -i "s/^enabled.*/enabled=0/g" $2/$3
|
85
IMG/cpio/ventoy/hook/rhel6/udev_disk_hook.sh
Normal file
85
IMG/cpio/ventoy/hook/rhel6/udev_disk_hook.sh
Normal file
@@ -0,0 +1,85 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
ventoy_os_install_dmsetup() {
|
||||
vtlog "ventoy_os_install_dmsetup $1"
|
||||
|
||||
vt_usb_disk=$1
|
||||
|
||||
$BUSYBOX_PATH/modprobe dm-mod
|
||||
$BUSYBOX_PATH/modprobe linear
|
||||
|
||||
# dump iso file location
|
||||
$VTOY_PATH/tool/vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
|
||||
|
||||
# install dmsetup
|
||||
LINE=$($GREP 'device-mapper-[0-9].*\.rpm' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
install_rpm_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
|
||||
vtlog "dmsetup install finish, now check it..."
|
||||
|
||||
dmsetup_path=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
vterr "dmsetup still not found after install"
|
||||
elif $dmsetup_path info >> $VTLOG 2>&1; then
|
||||
vtlog "$dmsetup_path work ok"
|
||||
else
|
||||
vterr "$dmsetup_path not work"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
# /dev/loop7 come first
|
||||
if [ "$1" = "loop7" ] && [ -b $VTOY_DM_PATH ]; then
|
||||
ventoy_copy_device_mapper /dev/loop7
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
dmsetup_path=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
|
||||
fi
|
||||
|
||||
|
||||
#some distro add there repo file to /etc/anaconda.repos.d/ which will cause error during installation
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $VTOY_PATH/hook/rhel6/anaconda-repo-listen.sh /etc/anaconda.repos.d:n &
|
||||
|
||||
ventoy_udev_disk_common_hook $* "noreplace"
|
||||
|
||||
$BUSYBOX_PATH/mount $VTOY_DM_PATH /mnt/ventoy
|
||||
|
||||
#
|
||||
# We do a trick for rhel6 series here.
|
||||
# Use /dev/loop7 and wapper it as a removable cdrom with bind mount.
|
||||
# Then the anaconda installer will accept /dev/loop7 as the install medium.
|
||||
#
|
||||
ventoy_copy_device_mapper /dev/loop7
|
||||
|
||||
$BUSYBOX_PATH/cp -a /sys/devices/virtual/block/loop7 /tmp/ >> $VTLOG 2>&1
|
||||
echo 19 > /tmp/loop7/capability
|
||||
$BUSYBOX_PATH/mount --bind /tmp/loop7 /sys/block/loop7 >> $VTLOG 2>&1
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
27
IMG/cpio/ventoy/hook/rhel6/ventoy-hook.sh
Normal file
27
IMG/cpio/ventoy/hook/rhel6/ventoy-hook.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$BUSYBOX_PATH/mkdir -p /etc/anaconda.repos.d /mnt/ventoy
|
||||
ventoy_print_yum_repo "ventoy" "file:///mnt/ventoy" > /etc/anaconda.repos.d/ventoy.repo
|
||||
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/rhel6/udev_disk_hook.sh %k"
|
||||
ventoy_add_kernel_udev_rule "loop7" "$VTOY_PATH/hook/rhel6/udev_disk_hook.sh %k"
|
29
IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh
Normal file
29
IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
|
||||
|
||||
# suppress write protected mount warning
|
||||
if [ -e /usr/sbin/anaconda-diskroot ]; then
|
||||
$SED 's/^mount $dev $repodir/mount -oro $dev $repodir/' -i /usr/sbin/anaconda-diskroot
|
||||
fi
|
41
IMG/cpio/ventoy/hook/slackware/udev_disk_hook.sh
Normal file
41
IMG/cpio/ventoy/hook/slackware/udev_disk_hook.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
#
|
||||
# make a fake cdrom link
|
||||
#
|
||||
if [ -e /dev/sr3 ]; then
|
||||
if ! [ -e /dev/hdp ]; then
|
||||
ln -s $VTOY_DM_PATH /dev/hdp
|
||||
fi
|
||||
else
|
||||
ln -s $VTOY_DM_PATH /dev/sr3
|
||||
fi
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
8
IMG/cpio/ventoy/hook/slackware/ventoy-hook.sh
Normal file
8
IMG/cpio/ventoy/hook/slackware/ventoy-hook.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/ventoy/busybox/sh
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/slackware/udev_disk_hook.sh %k noreplace"
|
||||
|
60
IMG/cpio/ventoy/hook/suse/udev_disk_hook.sh
Normal file
60
IMG/cpio/ventoy/hook/suse/udev_disk_hook.sh
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
ventoy_os_install_dmsetup() {
|
||||
vtlog "ventoy_os_install_dmsetup $1"
|
||||
|
||||
vt_usb_disk=$1
|
||||
|
||||
# dump iso file location
|
||||
$VTOY_PATH/tool/vtoydm -i -f $VTOY_PATH/ventoy_image_map -d ${vt_usb_disk} > $VTOY_PATH/iso_file_list
|
||||
|
||||
# install dmsetup
|
||||
LINE=$($GREP 'device-mapper-[0-9]\..*\.rpm' $VTOY_PATH/iso_file_list)
|
||||
if [ $? -eq 0 ]; then
|
||||
install_rpm_from_line "$LINE" ${vt_usb_disk}
|
||||
fi
|
||||
|
||||
vtlog "dmsetup install finish, now check it..."
|
||||
|
||||
dmsetup_path=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
vterr "dmsetup still not found after install"
|
||||
elif $dmsetup_path info >> $VTLOG 2>&1; then
|
||||
vtlog "$dmsetup_path work ok"
|
||||
else
|
||||
vterr "$dmsetup_path not work"
|
||||
fi
|
||||
}
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
dmsetup_path=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$dmsetup_path" ]; then
|
||||
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
24
IMG/cpio/ventoy/hook/suse/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/suse/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/suse/udev_disk_hook.sh %k"
|
45
IMG/cpio/ventoy/hook/tinycore/udev_disk_hook.sh
Normal file
45
IMG/cpio/ventoy/hook/tinycore/udev_disk_hook.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# TinyCore linux distro doesn't contain dmsetup, we use aoe here
|
||||
sudo $BUSYBOX_PATH/modprobe aoe aoe_iflist=lo
|
||||
if [ -e /sys/module/aoe ]; then
|
||||
VBLADE_BIN=$(ventoy_get_vblade_bin)
|
||||
sudo $VBLADE_BIN -r -f $VTOY_PATH/ventoy_image_map 9 0 lo "/dev/${1:0:-1}" &
|
||||
|
||||
while ! [ -b /dev/etherd/e9.0 ]; do
|
||||
vtlog 'Wait for /dev/etherd/e9.0 ....'
|
||||
$SLEEP 0.1
|
||||
done
|
||||
|
||||
sudo $BUSYBOX_PATH/cp -a /dev/etherd/e9.0 "/dev/$1"
|
||||
|
||||
ventoy_find_bin_run rebuildfstab
|
||||
else
|
||||
vterr "aoe driver module load failed..."
|
||||
fi
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
24
IMG/cpio/ventoy/hook/tinycore/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/tinycore/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule_with_name "$VTOY_PATH/hook/tinycore/udev_disk_hook.sh %k" "90-ventoy.rules"
|
424
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
Normal file
424
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
Normal file
@@ -0,0 +1,424 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
VTOY_PATH=/ventoy
|
||||
BUSYBOX_PATH=$VTOY_PATH/busybox
|
||||
VTLOG=$VTOY_PATH/log
|
||||
FIND=$BUSYBOX_PATH/find
|
||||
GREP=$BUSYBOX_PATH/grep
|
||||
EGREP=$BUSYBOX_PATH/egrep
|
||||
CAT=$BUSYBOX_PATH/cat
|
||||
AWK=$BUSYBOX_PATH/awk
|
||||
SED=$BUSYBOX_PATH/sed
|
||||
SLEEP=$BUSYBOX_PATH/sleep
|
||||
HEAD=$BUSYBOX_PATH/head
|
||||
VTOY_DM_PATH=/dev/mapper/ventoy
|
||||
VTOY_DEBUG_LEVEL=$($BUSYBOX_PATH/hexdump -n 1 -s 430 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param)
|
||||
|
||||
if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then
|
||||
if [ -e /dev/console ]; then
|
||||
VTLOG=/dev/console
|
||||
fi
|
||||
fi
|
||||
|
||||
vtlog() {
|
||||
if [ "$VTLOG" = "$VTOY_PATH/log" ]; then
|
||||
echo "$*" >>$VTLOG
|
||||
else
|
||||
echo -e "\033[32m $* \033[0m" > $VTLOG
|
||||
$SLEEP 2
|
||||
fi
|
||||
}
|
||||
|
||||
vterr() {
|
||||
if [ "$VTLOG" = "$VTOY_PATH/log" ]; then
|
||||
echo "$*" >>$VTLOG
|
||||
else
|
||||
echo -e "\n\033[31m $* \033[0m" > $VTLOG
|
||||
$SLEEP 30
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
is_ventoy_hook_finished() {
|
||||
[ -e $VTOY_PATH/hook_finish ]
|
||||
}
|
||||
|
||||
set_ventoy_hook_finish() {
|
||||
echo 'Y' > $VTOY_PATH/hook_finish
|
||||
}
|
||||
|
||||
get_ventoy_disk_name() {
|
||||
line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ${line%%#*}
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
get_ventoy_iso_name() {
|
||||
line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ${line##*#}
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
wait_for_usb_disk_ready() {
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk ..."
|
||||
|
||||
if [ -e "${usb_disk}2" ]; then
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk finish"
|
||||
break
|
||||
else
|
||||
$SLEEP 0.3
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
is_ventoy_disk() {
|
||||
if $VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c "$1"; then
|
||||
$BUSYBOX_PATH/true
|
||||
else
|
||||
$BUSYBOX_PATH/false
|
||||
fi
|
||||
}
|
||||
|
||||
not_ventoy_disk() {
|
||||
if $VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c "$1"; then
|
||||
$BUSYBOX_PATH/false
|
||||
else
|
||||
$BUSYBOX_PATH/true
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_get_vblade_bin() {
|
||||
if $VTOY_PATH/tool/vblade_64 -t >>$VTLOG 2>&1; then
|
||||
echo $VTOY_PATH/tool/vblade_64
|
||||
else
|
||||
echo $VTOY_PATH/tool/vblade_32
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_find_bin_path() {
|
||||
if $BUSYBOX_PATH/which "$1" > /dev/null; then
|
||||
$BUSYBOX_PATH/which "$1"; return
|
||||
fi
|
||||
|
||||
for vt_path in '/bin' '/sbin' '/usr/bin' '/usr/sbin' '/usr/local/bin' '/usr/local/sbin' '/root/bin'; do
|
||||
if [ -e "$vt_path/$1" ]; then
|
||||
echo "$vt_path/$1"; return
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
||||
ventoy_find_bin_run() {
|
||||
vtsudo=0
|
||||
if [ "$1" = "sudo" ]; then
|
||||
shift
|
||||
vtsudo=1
|
||||
fi
|
||||
|
||||
vtbinpath=$(ventoy_find_bin_path "$1")
|
||||
if [ -n "$vtbinpath" ]; then
|
||||
shift
|
||||
|
||||
if [ $vtsudo -eq 0 ]; then
|
||||
vtlog "$vtbinpath $*"
|
||||
$vtbinpath $*
|
||||
else
|
||||
vtlog "sudo $vtbinpath $*"
|
||||
sudo $vtbinpath $*
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_get_module_postfix() {
|
||||
vtKerVer=$($BUSYBOX_PATH/uname -r)
|
||||
vtLine=$($FIND /lib/modules/$vtKerVer/ -name *.ko* | $HEAD -n1)
|
||||
vtComp=${vtLine##*/*.ko}
|
||||
echo "ko$vtComp"
|
||||
}
|
||||
|
||||
ventoy_check_dm_module() {
|
||||
if $GREP -q 'device-mapper' /proc/devices; then
|
||||
$BUSYBOX_PATH/true; return
|
||||
fi
|
||||
|
||||
vtlog "device-mapper NOT found in /proc/devices, try to load kernel module"
|
||||
$BUSYBOX_PATH/modprobe dm_mod >>$VTLOG 2>&1
|
||||
$BUSYBOX_PATH/modprobe dm-mod >>$VTLOG 2>&1
|
||||
|
||||
if ! $GREP -q 'device-mapper' /proc/devices; then
|
||||
vtlog "modprobe failed, now try to insmod ko..."
|
||||
|
||||
$FIND /lib/modules/ -name "dm-mod.ko*" | while read vtline; do
|
||||
vtlog "insmode $vtline "
|
||||
$BUSYBOX_PATH/insmod $vtline >>$VTLOG 2>&1
|
||||
done
|
||||
fi
|
||||
|
||||
if $GREP -q 'device-mapper' /proc/devices; then
|
||||
vtlog "device-mapper found in /proc/devices after retry"
|
||||
$BUSYBOX_PATH/true; return
|
||||
else
|
||||
vtlog "device-mapper still NOT found in /proc/devices after retry"
|
||||
$BUSYBOX_PATH/false; return
|
||||
fi
|
||||
}
|
||||
|
||||
create_ventoy_device_mapper() {
|
||||
vtlog "create_ventoy_device_mapper $*"
|
||||
|
||||
VT_DM_BIN=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$VT_DM_BIN" ]; then
|
||||
vtlog "no dmsetup avaliable, lastly try inbox dmsetup"
|
||||
VT_DM_BIN=$VTOY_PATH/tool/dmsetup
|
||||
fi
|
||||
|
||||
vtlog "dmsetup avaliable in system $VT_DM_BIN"
|
||||
|
||||
if ventoy_check_dm_module "$1"; then
|
||||
vtlog "device-mapper module check success"
|
||||
else
|
||||
vterr "Error: no dm module avaliable"
|
||||
fi
|
||||
|
||||
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $1 > $VTOY_PATH/ventoy_dm_table
|
||||
if [ -z "$2" ]; then
|
||||
$VT_DM_BIN create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
|
||||
else
|
||||
$VT_DM_BIN "$2" create ventoy $VTOY_PATH/ventoy_dm_table >>$VTLOG 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
wait_for_ventoy_dm_disk_label() {
|
||||
DM=$($BUSYBOX_PATH/readlink $VTOY_DM_PATH)
|
||||
vtlog "wait_for_ventoy_dm_disk_label $DM ..."
|
||||
|
||||
for i in 0 1 2 3 4 5 6 7 8 9; do
|
||||
vtlog "i=$i ####### ls /dev/disk/by-label/"
|
||||
ls -l /dev/disk/by-label/ >> $VTLOG
|
||||
|
||||
if ls -l /dev/disk/by-label/ | $GREP -q "$DM"; then
|
||||
break
|
||||
else
|
||||
$SLEEP 0.3
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
install_udeb_pkg() {
|
||||
if ! [ -e "$1" ]; then
|
||||
$BUSYBOX_PATH/false
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -d /tmp/vtoy_udeb ]; then
|
||||
$BUSYBOX_PATH/rm -rf /tmp/vtoy_udeb
|
||||
fi
|
||||
|
||||
$BUSYBOX_PATH/mkdir -p /tmp/vtoy_udeb
|
||||
$BUSYBOX_PATH/cp -a "$1" /tmp/vtoy_udeb/
|
||||
|
||||
CURDIR=$($BUSYBOX_PATH/pwd)
|
||||
cd /tmp/vtoy_udeb
|
||||
|
||||
$BUSYBOX_PATH/ar x "$1"
|
||||
|
||||
if [ -e 'data.tar.gz' ]; then
|
||||
$BUSYBOX_PATH/tar -xzf data.tar.gz -C /
|
||||
elif [ -e 'data.tar.xz' ]; then
|
||||
$BUSYBOX_PATH/tar -xJf data.tar.xz -C /
|
||||
elif [ -e 'data.tar.bz2' ]; then
|
||||
$BUSYBOX_PATH/tar -xjf data.tar.bz2 -C /
|
||||
elif [ -e 'data.tar.lzma' ]; then
|
||||
$BUSYBOX_PATH/tar -xaf data.tar.lzma -C /
|
||||
fi
|
||||
|
||||
if [ -e 'control.tar.gz' ]; then
|
||||
$BUSYBOX_PATH/tar -xzf control.tar.gz -C /
|
||||
elif [ -e 'control.tar.xz' ]; then
|
||||
$BUSYBOX_PATH/tar -xJf control.tar.xz -C /
|
||||
elif [ -e 'control.tar.bz2' ]; then
|
||||
$BUSYBOX_PATH/tar -xjf control.tar.bz2 -C /
|
||||
elif [ -e 'control.tar.lzma' ]; then
|
||||
$BUSYBOX_PATH/tar -xaf control.tar.lzma -C /
|
||||
fi
|
||||
|
||||
cd $CURDIR
|
||||
$BUSYBOX_PATH/rm -rf /tmp/vtoy_udeb
|
||||
$BUSYBOX_PATH/true
|
||||
}
|
||||
|
||||
|
||||
install_udeb_from_line() {
|
||||
vtlog "install_udeb_from_line $1"
|
||||
|
||||
if ! [ -b "$2" ]; then
|
||||
vterr "disk #$2# not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
sector=$(echo $1 | $AWK '{print $(NF-1)}')
|
||||
length=$(echo $1 | $AWK '{print $NF}')
|
||||
vtlog "sector=$sector length=$length"
|
||||
|
||||
$VTOY_PATH/tool/vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${2} -s $sector -l $length -o /tmp/xxx.udeb
|
||||
if [ -e /tmp/xxx.udeb ]; then
|
||||
vtlog "extract udeb file from iso success"
|
||||
else
|
||||
vterr "extract udeb file from iso fail"
|
||||
return
|
||||
fi
|
||||
|
||||
install_udeb_pkg /tmp/xxx.udeb
|
||||
$BUSYBOX_PATH/rm -f /tmp/xxx.udeb
|
||||
}
|
||||
|
||||
extract_file_from_line() {
|
||||
vtlog "extract_file_from_line $1 disk=#$2#"
|
||||
if ! [ -b "$2" ]; then
|
||||
vterr "disk #$2# not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
sector=$(echo $1 | $AWK '{print $(NF-1)}')
|
||||
length=$(echo $1 | $AWK '{print $NF}')
|
||||
vtlog "sector=$sector length=$length"
|
||||
|
||||
$VTOY_PATH/tool/vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${2} -s $sector -l $length -o $3
|
||||
if [ -e $3 ]; then
|
||||
vtlog "extract file from iso success"
|
||||
$BUSYBOX_PATH/true
|
||||
else
|
||||
vterr "extract file from iso fail"
|
||||
$BUSYBOX_PATH/false
|
||||
fi
|
||||
}
|
||||
|
||||
install_rpm_from_line() {
|
||||
vtlog "install_rpm_from_line $1 disk=#$2#"
|
||||
|
||||
if ! [ -b "$2" ]; then
|
||||
vterr "disk #$2# not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
sector=$(echo $1 | $AWK '{print $(NF-1)}')
|
||||
length=$(echo $1 | $AWK '{print $NF}')
|
||||
vtlog "sector=$sector length=$length"
|
||||
|
||||
$VTOY_PATH/tool/vtoydm -e -f $VTOY_PATH/ventoy_image_map -d ${2} -s $sector -l $length -o /tmp/xxx.rpm
|
||||
if [ -e /tmp/xxx.rpm ]; then
|
||||
vtlog "extract rpm file from iso success"
|
||||
else
|
||||
vterr "extract rpm file from iso fail"
|
||||
return
|
||||
fi
|
||||
|
||||
CURPWD=$($BUSYBOX_PATH/pwd)
|
||||
|
||||
cd /
|
||||
vtlog "install rpm..."
|
||||
$BUSYBOX_PATH/rpm2cpio /tmp/xxx.rpm | $BUSYBOX_PATH/cpio -idm 2>>$VTLOG
|
||||
cd $CURPWD
|
||||
|
||||
$BUSYBOX_PATH/rm -f /tmp/xxx.rpm
|
||||
}
|
||||
|
||||
dump_whole_iso_file() {
|
||||
$VTOY_PATH/tool/vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $usb_disk | while read vtline; do
|
||||
vtlog "dmtable line: $vtline"
|
||||
vtcount=$(echo $vtline | $AWK '{print $2}')
|
||||
vtoffset=$(echo $vtline | $AWK '{print $NF}')
|
||||
$BUSYBOX_PATH/dd if=$usb_disk of="$1" bs=512 count=$vtcount skip=$vtoffset oflag=append conv=notrunc
|
||||
done
|
||||
}
|
||||
|
||||
ventoy_copy_device_mapper() {
|
||||
if [ -L $VTOY_DM_PATH ]; then
|
||||
vtlog "replace block device link $1..."
|
||||
$BUSYBOX_PATH/mv "$1" $VTOY_PATH/dev_backup_${1#/dev/}
|
||||
VT_MAPPER_LINK=$($BUSYBOX_PATH/readlink $VTOY_DM_PATH)
|
||||
$BUSYBOX_PATH/cp -a "/dev/mapper/$VT_MAPPER_LINK" "$1"
|
||||
elif [ -b $VTOY_DM_PATH ]; then
|
||||
vtlog "replace block device $1..."
|
||||
$BUSYBOX_PATH/mv "$1" $VTOY_PATH/dev_backup_${1#/dev/}
|
||||
$BUSYBOX_PATH/cp -a "$VTOY_DM_PATH" "$1"
|
||||
else
|
||||
|
||||
vtlog "$VTOY_DM_PATH not exist, now check /dev/dm-X ..."
|
||||
VT_DM_BIN=$(ventoy_find_bin_path dmsetup)
|
||||
if [ -z "$VT_DM_BIN" ]; then
|
||||
vtlog "no dmsetup avaliable, lastly try inbox dmsetup"
|
||||
VT_DM_BIN=$VTOY_PATH/tool/dmsetup
|
||||
fi
|
||||
|
||||
DM_VT_ID=$($VT_DM_BIN ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
|
||||
vtlog "DM_VT_ID=$DM_VT_ID ..."
|
||||
$BUSYBOX_PATH/mv "$1" $VTOY_PATH/dev_backup_${1#/dev/}
|
||||
$BUSYBOX_PATH/mknod -m 0666 "$1" b $DM_VT_ID
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_udev_disk_common_hook() {
|
||||
|
||||
VTDISK="${1:0:-1}"
|
||||
|
||||
# create device mapper for iso image file
|
||||
if create_ventoy_device_mapper "/dev/$VTDISK" --readonly; then
|
||||
vtlog "==== create ventoy device mapper success ===="
|
||||
else
|
||||
vtlog "==== create ventoy device mapper failed ===="
|
||||
|
||||
$SLEEP 5
|
||||
|
||||
if $GREP -q "/dev/$VTDISK" /proc/mounts; then
|
||||
$GREP "/dev/$VTDISK" /proc/mounts | while read vtLine; do
|
||||
vtPart=$(echo $vtLine | $AWK '{print $1}')
|
||||
vtMnt=$(echo $vtLine | $AWK '{print $2}')
|
||||
vtlog "$vtPart is mounted on $vtMnt now umount it ..."
|
||||
$BUSYBOX_PATH/umount $vtMnt
|
||||
done
|
||||
fi
|
||||
|
||||
if create_ventoy_device_mapper "/dev/$VTDISK" --readonly; then
|
||||
vtlog "==== create ventoy device mapper success after retry ===="
|
||||
else
|
||||
vtlog "==== create ventoy device mapper failed after retry ===="
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$2" = "noreplace" ]; then
|
||||
vtlog "no need to replace block device"
|
||||
else
|
||||
ventoy_copy_device_mapper "/dev/$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
98
IMG/cpio/ventoy/hook/ventoy-os-lib.sh
Normal file
98
IMG/cpio/ventoy/hook/ventoy-os-lib.sh
Normal file
@@ -0,0 +1,98 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
VT_RULE_DIR_PREFIX=""
|
||||
VT_PRINTK_LEVEL=0
|
||||
VT_UDEV_RULE_FILE_NAME="99-ventoy.rules"
|
||||
VT_UDEV_RULE_PREFIX="ACTION==\"add\", SUBSYSTEM==\"block\","
|
||||
|
||||
ventoy_close_printk() {
|
||||
VT_PRINTK_LEVEL=$($CAT /proc/sys/kernel/printk | $AWK '{print $1}')
|
||||
if [ -e /proc/sys/kernel/printk ]; then
|
||||
echo 0 > /proc/sys/kernel/printk
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_restore_printk() {
|
||||
if [ -e /proc/sys/kernel/printk ]; then
|
||||
echo $VT_PRINTK_LEVEL > /proc/sys/kernel/printk
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_set_rule_dir_prefix() {
|
||||
VT_RULE_DIR_PREFIX=$1
|
||||
}
|
||||
|
||||
ventoy_get_udev_conf_dir() {
|
||||
if [ -d $VT_RULE_DIR_PREFIX/etc/udev/rules.d ]; then
|
||||
VT_RULE_PATH=$VT_RULE_DIR_PREFIX/etc/udev/rules.d
|
||||
elif [ -d $VT_RULE_DIR_PREFIX/lib/udev/rules.d ]; then
|
||||
VT_RULE_PATH=$VT_RULE_DIR_PREFIX/lib/udev/rules.d
|
||||
else
|
||||
$BUSYBOX_PATH/mkdir -p $VT_RULE_DIR_PREFIX/etc/udev/rules.d
|
||||
VT_RULE_PATH=$VT_RULE_DIR_PREFIX/etc/udev/rules.d
|
||||
fi
|
||||
echo -n "$VT_RULE_PATH"
|
||||
}
|
||||
|
||||
ventoy_get_udev_conf_path() {
|
||||
VT_RULE_DIR=$(ventoy_get_udev_conf_dir)
|
||||
echo "$VT_RULE_DIR/$VT_UDEV_RULE_FILE_NAME"
|
||||
}
|
||||
|
||||
ventoy_add_kernel_udev_rule() {
|
||||
VT_UDEV_RULE_PATH=$(ventoy_get_udev_conf_path)
|
||||
echo "KERNEL==\"$1\", $VT_UDEV_RULE_PREFIX RUN+=\"$2\"" >> $VT_UDEV_RULE_PATH
|
||||
}
|
||||
|
||||
ventoy_add_udev_rule_with_name() {
|
||||
VT_UDEV_RULE_DIR=$(ventoy_get_udev_conf_dir)
|
||||
echo "KERNEL==\"*2\", $VT_UDEV_RULE_PREFIX RUN+=\"$1\"" >> $VT_UDEV_RULE_DIR/$2
|
||||
}
|
||||
|
||||
ventoy_add_udev_rule_with_path() {
|
||||
echo "KERNEL==\"*2\", $VT_UDEV_RULE_PREFIX RUN+=\"$1\"" >> $2
|
||||
}
|
||||
|
||||
ventoy_add_udev_rule() {
|
||||
VT_UDEV_RULE_PATH=$(ventoy_get_udev_conf_path)
|
||||
echo "KERNEL==\"*2\", $VT_UDEV_RULE_PREFIX RUN+=\"$1\"" >> $VT_UDEV_RULE_PATH
|
||||
}
|
||||
|
||||
#
|
||||
# It seems there is a bug in somw version of systemd-udevd
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=869719
|
||||
#
|
||||
ventoy_systemd_udevd_work_around() {
|
||||
VTSYSTEMUDEV="$VT_RULE_DIR_PREFIX/lib/systemd/system/systemd-udevd.service"
|
||||
if [ -e $VTSYSTEMUDEV ]; then
|
||||
if $GREP -q 'SystemCallArchitectures.*native' $VTSYSTEMUDEV; then
|
||||
$SED "s/.*\(SystemCallArchitectures.*native\)/#\1/g" -i $VTSYSTEMUDEV
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_print_yum_repo() {
|
||||
echo "[$1]"
|
||||
echo "name=$1"
|
||||
echo "baseurl=$2"
|
||||
echo "enabled=1"
|
||||
echo "gpgcheck=0"
|
||||
echo "priority=0"
|
||||
}
|
32
IMG/cpio/ventoy/hook/xen/udev_disk_hook.sh
Normal file
32
IMG/cpio/ventoy/hook/xen/udev_disk_hook.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook $*
|
||||
|
||||
# trick for xen6
|
||||
ventoy_copy_device_mapper /dev/sr7
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
24
IMG/cpio/ventoy/hook/xen/ventoy-hook.sh
Normal file
24
IMG/cpio/ventoy/hook/xen/ventoy-hook.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/xen/udev_disk_hook.sh %k"
|
Reference in New Issue
Block a user