diff --git a/vtoyboot/distros/dracut/check.sh b/vtoyboot/distros/dracut/check.sh deleted file mode 100644 index afcbb8e..0000000 --- a/vtoyboot/distros/dracut/check.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -vtoy_check_dracut() { - if which dracut >/dev/null 2>&1; then - if dracut --list-modules | grep -q '^dm$'; then - [ -n "1" ]; return - fi - fi - [ -z "1" ] -} diff --git a/vtoyboot/distros/dracut/module-setup.sh b/vtoyboot/distros/dracut/module-setup.sh deleted file mode 100644 index bb6b460..0000000 --- a/vtoyboot/distros/dracut/module-setup.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -check() { - require_binaries sed grep awk || return 1 - return 255 -} - -depends() { - echo dm - return 0 -} - - -install() { - inst_multiple sed grep awk dd sort head find basename xzcat zcat vtoydump vtoypartx vtoydmpatch vtoytool - inst_hook initqueue/settled 99 "$moddir/ventoy-settled.sh" - dracut_need_initqueue -} diff --git a/vtoyboot/distros/dracut/ventoy-settled.sh b/vtoyboot/distros/dracut/ventoy-settled.sh deleted file mode 100644 index 0858925..0000000 --- a/vtoyboot/distros/dracut/ventoy-settled.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh - -########################### -########################### -#AUTO_INSERT_COMMON_FUNC - -#check for efivarfs -ventoy_check_efivars - -if ! vtoydump > /dev/null 2>&1; then - info 'vtoydump failed' - return -fi - -#already done -if dmsetup ls | grep -q ventoy; then - info 'ventoy already exist' - return -fi - -ventoy_dm_patch_proc_begin - -#flush multipath before dmsetup -multipath -F > /dev/null 2>&1 - -vtoydump -L > /ventoy_table -if dmsetup create ventoy /ventoy_table; then - : -else - sleep 3 - multipath -F > /dev/null 2>&1 - dmsetup create ventoy /ventoy_table -fi - -DEVDM=/dev/mapper/ventoy - -loop=0 -while ! [ -e $DEVDM ]; do - sleep 0.5 - let loop+=1 - if [ $loop -gt 10 ]; then - echo "Waiting for ventoy device ..." > /dev/console - fi - - if [ $loop -gt 10 -a $loop -lt 15 ]; then - multipath -F > /dev/null 2>&1 - dmsetup create ventoy /ventoy_table - fi -done - -for ID in $(vtoypartx $DEVDM -oNR | grep -v NR); do - PART_START=$(vtoypartx $DEVDM -n$ID -oSTART,SECTORS | grep -v START | awk '{print $1}') - PART_SECTOR=$(vtoypartx $DEVDM -n$ID -oSTART,SECTORS | grep -v START | awk '{print $2}') - - echo "0 $PART_SECTOR linear $DEVDM $PART_START" > /ventoy_part_table - dmsetup create ventoy$ID /ventoy_part_table -done - -rm -f /ventoy_table -rm -f /ventoy_part_table - -ventoy_dm_patch_proc_end diff --git a/vtoyboot/distros/dracut/vtoy.sh b/vtoyboot/distros/dracut/vtoy.sh deleted file mode 100644 index dab3cce..0000000 --- a/vtoyboot/distros/dracut/vtoy.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -. ./tools/efi_legacy_grub.sh - -if [ -e /lib/dracut/dracut-install ]; then - vtmodpath=/lib/dracut/modules.d/99ventoy -else - vtmodpath=/usr/lib/dracut/modules.d/99ventoy -fi - -if [ -d /etc/dracut.conf.d ]; then - dracutConfPath=/etc/dracut.conf.d -else - dracutConfPath=/usr/lib/dracut/dracut.conf.d -fi - - -rm -f /bin/vtoydump /bin/vtoypartx /bin/vtoytool /bin/vtoydmpatch -rm -f $dracutConfPath/ventoy.conf -rm -rf $vtmodpath -mkdir -p $vtmodpath - -cp -a $vtdumpcmd /bin/vtoydump -cp -a $partxcmd /bin/vtoypartx -cp -a $vtoytool /bin/vtoytool -cat /bin/vtoydump $dmpatchko > /bin/vtoydmpatch -cp -a ./distros/$initrdtool/module-setup.sh $vtmodpath/ -cp -a ./distros/$initrdtool/ventoy-settled.sh $vtmodpath/ - -#early centos release doesn't have require_binaries -if [ -e $vtmodpath/../../dracut-functions ]; then - if grep -q require_binaries $vtmodpath/../../dracut-functions; then - : - else - sed "/require_binaries/d" -i $vtmodpath/module-setup.sh - fi -fi - - -for md in $(cat ./tools/vtoydrivers); do - if [ -n "$md" ]; then - if modinfo -n $md 2>/dev/null | grep -q '\.ko'; then - extdrivers="$extdrivers $md" - fi - fi -done - - -#generate dracut conf file -cat >$dracutConfPath/ventoy.conf < /dev/null 2>&1 - fi -fi - - -if [ -e /sys/firmware/efi ]; then - if [ -e /dev/mapper/ventoy ]; then - echo "This is ventoy enviroment" - else - update_grub_config - install_legacy_bios_grub - fi - - if [ "$1" = "-s" ]; then - recover_shim_efi - else - replace_shim_efi - fi - - if [ -d /boot/EFI/EFI/mageia ]; then - if ! [ -d /boot/EFI/EFI/boot ]; then - mkdir -p /boot/EFI/EFI/boot - if [ -f /boot/EFI/EFI/mageia/grubx64.efi ]; then - cp -a /boot/EFI/EFI/mageia/grubx64.efi /boot/EFI/EFI/boot/bootx64.efi - fi - fi - fi - -fi diff --git a/vtoyboot/distros/initramfstool/check.sh b/vtoyboot/distros/initramfstool/check.sh deleted file mode 100644 index 702a0e3..0000000 --- a/vtoyboot/distros/initramfstool/check.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -vtoy_false() { - [ -z "1" ] -} - -vtoy_true() { - [ -n "1" ] -} - - -vtoy_check_initramfs_tool() { - if which update-initramfs >/dev/null 2>&1; then - - if ! [ -f /usr/share/initramfs-tools/hook-functions ]; then - vtoy_false; return - fi - - if ! [ -f /usr/share/initramfs-tools/hooks/dmsetup ]; then - vtoy_false; return - fi - - if ! [ -d /etc/initramfs-tools/scripts/local-top ]; then - vtoy_false; return - fi - - vtoy_true - else - vtoy_false - fi -} diff --git a/vtoyboot/distros/initramfstool/vtoy-hook.sh b/vtoyboot/distros/initramfstool/vtoy-hook.sh deleted file mode 100644 index d5418b6..0000000 --- a/vtoyboot/distros/initramfstool/vtoy-hook.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -PREREQ="dmsetup" -prereqs() { - echo "$PREREQ" -} - -case $1 in - prereqs) - prereqs - exit 0 - ;; -esac - -. /usr/share/initramfs-tools/hook-functions - -# Begin real processing below this line - -for md in $(cat /sbin/vtoydrivers); do - if [ -n "$md" ]; then - if modinfo -n $md 2>/dev/null | grep -q '\.ko'; then - force_load $md - fi - fi -done - -for ef in dd sort head find basename xzcat zcat; do - for vp in /bin /sbin /usr/bin /usr/sbin; do - if [ -f $vp/$ef ]; then - copy_exec $vp/$ef /sbin - break - fi - done -done - -copy_exec /sbin/vtoytool /sbin -copy_exec /sbin/vtoydmpatch /sbin -copy_exec /sbin/vtoypartx /sbin -copy_exec /sbin/vtoydump /sbin diff --git a/vtoyboot/distros/initramfstool/vtoy-local-top.sh b/vtoyboot/distros/initramfstool/vtoy-local-top.sh deleted file mode 100644 index ad2f9e4..0000000 --- a/vtoyboot/distros/initramfstool/vtoy-local-top.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -########################### -########################### -#AUTO_INSERT_COMMON_FUNC - - -vtoy_wait_for_device() { - while ! vtoydump > /dev/null 2>&1; do - sleep 0.5 - done -} - -vtoy_device_mapper_proc() { - #flush multipath before dmsetup - multipath -F > /dev/null 2>&1 - - vtoydump -L > /ventoy_table - if dmsetup create ventoy /ventoy_table; then - : - else - sleep 3 - multipath -F > /dev/null 2>&1 - dmsetup create ventoy /ventoy_table - fi - - - DEVDM=/dev/mapper/ventoy - - loop=0 - while ! [ -e $DEVDM ]; do - sleep 0.5 - let loop+=1 - if [ $loop -gt 10 ]; then - echo "Waiting for ventoy device ..." > /dev/console - fi - - if [ $loop -gt 10 -a $loop -lt 15 ]; then - multipath -F > /dev/null 2>&1 - dmsetup create ventoy /ventoy_table - fi - done - - - for ID in $(vtoypartx $DEVDM -oNR | grep -v NR); do - PART_START=$(vtoypartx $DEVDM -n$ID -oSTART,SECTORS | grep -v START | awk '{print $1}') - PART_SECTOR=$(vtoypartx $DEVDM -n$ID -oSTART,SECTORS | grep -v START | awk '{print $2}') - - echo "0 $PART_SECTOR linear $DEVDM $PART_START" > /ventoy_part_table - dmsetup create ventoy$ID /ventoy_part_table - done - - rm -f /ventoy_table - rm -f /ventoy_part_table -} - -case $1 in - prereqs) - exit 0 - ;; -esac - -#check for efivarfs -ventoy_check_efivars - -if vtoydump -c > /dev/null 2>&1; then - vtoy_wait_for_device - ventoy_dm_patch_proc_begin - vtoy_device_mapper_proc - ventoy_dm_patch_proc_end -fi - diff --git a/vtoyboot/distros/initramfstool/vtoy.sh b/vtoyboot/distros/initramfstool/vtoy.sh deleted file mode 100644 index 234ce29..0000000 --- a/vtoyboot/distros/initramfstool/vtoy.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -vtoy_clean_env() { - rm -f /sbin/vtoydump /sbin/vtoypartx /sbin/vtoytool /sbin/vtoydmpatch /sbin/vtoydrivers - rm -f /usr/share/initramfs-tools/hooks/vtoy-hook.sh - rm -f /etc/initramfs-tools/scripts/local-top/vtoy-local-top.sh -} - -vtoy_efi_fixup() { - if [ -d /boot/efi/EFI ]; then - for f in 'boot/bootx64.efi' 'boot/BOOTX64.efi' 'boot/BOOTX64.EFI' 'BOOT/bootx64.efi' 'BOOT/BOOTX64.efi' 'BOOT/BOOTX64.EFI'; do - if [ -f /boot/efi/EFI/$f ]; then - return - fi - done - fi - - Dirs=$(ls /boot/efi/EFI) - - if ! [ -d /boot/efi/EFI/boot ]; then - mkdir -p /boot/efi/EFI/boot - fi - - for d in $Dirs; do - for e in 'grubx64.efi' 'GRUBX64.EFI' 'bootx64.efi' 'BOOTX64.EFI'; do - if [ -f "/boot/efi/EFI/$d/$e" ]; then - cp -a "/boot/efi/EFI/$d/$e" /boot/efi/EFI/boot/bootx64.efi - return - fi - done - done -} - -. ./tools/efi_legacy_grub.sh - -vtoy_clean_env - -cp -a $vtdumpcmd /sbin/vtoydump -cp -a $partxcmd /sbin/vtoypartx -cp -a $vtoytool /sbin/vtoytool -cat /sbin/vtoydump $dmpatchko > /sbin/vtoydmpatch -cp -a ./tools/vtoydrivers /sbin/vtoydrivers -cp -a ./distros/$initrdtool/vtoy-hook.sh /usr/share/initramfs-tools/hooks/ -cp -a ./distros/$initrdtool/vtoy-local-top.sh /etc/initramfs-tools/scripts/local-top/ - -echo "updating the initramfs, please wait ..." -update-initramfs -u - - -disable_grub_os_probe - -#wrapper grub-probe -echo "grub mkconfig ..." -PROBE_PATH=$(find_grub_probe_path) -MKCONFIG_PATH=$(find_grub_mkconfig_path) -echo "PROBE_PATH=$PROBE_PATH MKCONFIG_PATH=$MKCONFIG_PATH" - -if [ -e "$PROBE_PATH" -a -e "$MKCONFIG_PATH" ]; then - wrapper_grub_probe $PROBE_PATH - - GRUB_CFG_PATH=$(find_grub_config_path) - if [ -f "$GRUB_CFG_PATH" ]; then - echo "$MKCONFIG_PATH -o $GRUB_CFG_PATH" - $MKCONFIG_PATH -o $GRUB_CFG_PATH - else - echo "$MKCONFIG_PATH null" - $MKCONFIG_PATH > /dev/null 2>&1 - fi -fi - -#efi fixup -if [ -e /sys/firmware/efi ]; then - if [ -e /dev/mapper/ventoy ]; then - echo "This is ventoy enviroment" - else - update_grub_config - install_legacy_bios_grub - fi - - if [ "$1" = "-s" ]; then - recover_shim_efi - else - replace_shim_efi - fi - - vtoy_efi_fixup -fi - diff --git a/vtoyboot/distros/mkinitcpio/check.sh b/vtoyboot/distros/mkinitcpio/check.sh deleted file mode 100644 index c9aec1f..0000000 --- a/vtoyboot/distros/mkinitcpio/check.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -vtoy_check_mkinitcpio() { - if which mkinitcpio >/dev/null 2>&1; then - - for vtfile in '/etc/mkinitcpio.conf' '/usr/lib/initcpio/install/lvm2'; do - if ! [ -f $vtfile ]; then - [ -z "1" ]; return - fi - done - - [ -n "1" ] - else - [ -z "1" ] - fi -} diff --git a/vtoyboot/distros/mkinitcpio/ventoy-hook.sh b/vtoyboot/distros/mkinitcpio/ventoy-hook.sh deleted file mode 100644 index cb2d820..0000000 --- a/vtoyboot/distros/mkinitcpio/ventoy-hook.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -########################### -########################### -#AUTO_INSERT_COMMON_FUNC - - -vtoy_wait_for_device() { - local i=100 - - while [ $i -gt 0 ]; do - if vtoydump > /dev/null 2>&1; then - break - else - sleep 0.2 - fi - i=$((i - 1)) - done -} - -vtoy_device_mapper_proc() { - #flush multipath before dmsetup - multipath -F > /dev/null 2>&1 - - vtoydump -L > /ventoy_table - if dmsetup create ventoy /ventoy_table; then - : - else - sleep 3 - multipath -F > /dev/null 2>&1 - dmsetup create ventoy /ventoy_table - fi - - DEVDM=/dev/mapper/ventoy - - loop=0 - while ! [ -e $DEVDM ]; do - sleep 0.5 - let loop+=1 - if [ $loop -gt 10 ]; then - echo "Waiting for ventoy device ..." > /dev/console - fi - - if [ $loop -gt 10 -a $loop -lt 15 ]; then - multipath -F > /dev/null 2>&1 - dmsetup create ventoy /ventoy_table - fi - done - - for ID in $(vtoypartx $DEVDM -oNR | grep -v NR); do - PART_START=$(vtoypartx $DEVDM -n$ID -oSTART,SECTORS | grep -v START | awk '{print $1}') - PART_SECTOR=$(vtoypartx $DEVDM -n$ID -oSTART,SECTORS | grep -v START | awk '{print $2}') - - echo "0 $PART_SECTOR linear $DEVDM $PART_START" > /ventoy_part_table - dmsetup create ventoy$ID /ventoy_part_table - done - - rm -f /ventoy_table - rm -f /ventoy_part_table -} - -run_hook() { - #check for efivarfs - ventoy_check_efivars - - if vtoydump -c >/dev/null 2>/dev/null; then - vtoy_wait_for_device - if vtoydump > /dev/null 2>&1; then - ventoy_dm_patch_proc_begin - vtoy_device_mapper_proc - ventoy_dm_patch_proc_end - fi - fi -} - - diff --git a/vtoyboot/distros/mkinitcpio/ventoy-install.sh b/vtoyboot/distros/mkinitcpio/ventoy-install.sh deleted file mode 100644 index 617b054..0000000 --- a/vtoyboot/distros/mkinitcpio/ventoy-install.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -build() { - add_binary "dd" - add_binary "sort" - add_binary "head" - add_binary "find" - add_binary "xzcat" - add_binary "zcat" - add_binary "basename" - add_binary "vtoydump" - add_binary "vtoypartx" - add_binary "vtoydmpatch" - add_binary "vtoytool" - - for md in $(cat /sbin/vtoydrivers); do - if [ -n "$md" ]; then - if modinfo -n $md 2>/dev/null | grep -q '\.ko'; then - add_module $md - fi - fi - done - - add_runscript -} - -help() { - cat < -# -# 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 . -# -#************************************************************************************ - -. ./tools/efi_legacy_grub.sh - -vtoy_clean_env() { - rm -f /sbin/vtoydump /sbin/vtoypartx /sbin/vtoytool /sbin/vtoydmpatch /sbin/vtoydrivers - rm -f /usr/lib/initcpio/hooks/ventoy - rm -f /usr/lib/initcpio/install/ventoy -} - -vtoy_clean_env - -cp -a $vtdumpcmd /sbin/vtoydump -cp -a $partxcmd /sbin/vtoypartx -cp -a $vtoytool /sbin/vtoytool -cat /sbin/vtoydump $dmpatchko > /sbin/vtoydmpatch -cp -a ./tools/vtoydrivers /sbin/vtoydrivers -cp -a ./distros/$initrdtool/ventoy-install.sh /usr/lib/initcpio/install/ventoy -cp -a ./distros/$initrdtool/ventoy-hook.sh /usr/lib/initcpio/hooks/ventoy - -echo "updating the initramfs, please wait ..." - -if ! grep -q '^HOOKS=.*ventoy' /etc/mkinitcpio.conf; then - if grep -q '^HOOKS=.*lvm' /etc/mkinitcpio.conf; then - exthook='ventoy' - else - exthook='lvm2 ventoy' - fi - - if grep -q '^HOOKS=.*encrypt' /etc/mkinitcpio.conf; then - sed "s/\(^HOOKS=.*\)encrypt/\1 $exthook encrypt/" -i /etc/mkinitcpio.conf - elif grep -q "^HOOKS=\"" /etc/mkinitcpio.conf; then - sed "s/^HOOKS=\"\(.*\)\"/HOOKS=\"\1 $exthook\"/" -i /etc/mkinitcpio.conf - elif grep -q "^HOOKS=(" /etc/mkinitcpio.conf; then - sed "s/^HOOKS=(\(.*\))/HOOKS=(\1 $exthook)/" -i /etc/mkinitcpio.conf - fi -fi - -mkinitcpio -P - -disable_grub_os_probe - -#wrapper grub-probe -echo "grub mkconfig ..." -PROBE_PATH=$(find_grub_probe_path) -MKCONFIG_PATH=$(find_grub_mkconfig_path) -echo "PROBE_PATH=$PROBE_PATH MKCONFIG_PATH=$MKCONFIG_PATH" - -if [ -e "$PROBE_PATH" -a -e "$MKCONFIG_PATH" ]; then - wrapper_grub_probe $PROBE_PATH - - GRUB_CFG_PATH=$(find_grub_config_path) - if [ -f "$GRUB_CFG_PATH" ]; then - echo "$MKCONFIG_PATH -o $GRUB_CFG_PATH" - $MKCONFIG_PATH -o $GRUB_CFG_PATH - else - echo "$MKCONFIG_PATH null" - $MKCONFIG_PATH > /dev/null 2>&1 - fi -fi - - -if [ -e /sys/firmware/efi ]; then - if [ -e /dev/mapper/ventoy ]; then - echo "This is ventoy enviroment" - else - update_grub_config - install_legacy_bios_grub - fi - - if [ "$1" = "-s" ]; then - recover_shim_efi - else - replace_shim_efi - fi -fi diff --git a/vtoyboot/tools/01_linuxefi b/vtoyboot/tools/01_linuxefi deleted file mode 100644 index 8488045..0000000 --- a/vtoyboot/tools/01_linuxefi +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -e - -cat </dev/null 2>&1; then - which grub-probe - elif which grub2-probe >/dev/null 2>&1; then - which grub2-probe - else - echo "XXX" - fi -} - -find_grub_mkconfig_path() { - if which grub-mkconfig >/dev/null 2>&1; then - which grub-mkconfig - elif which grub2-mkconfig >/dev/null 2>&1; then - which grub2-mkconfig - else - echo "XXX" - fi -} - -find_grub_config_path() { - for i in grub.cfg grub2.cfg grub-efi.cfg grub2-efi.cfg; do - if readlink -f -e /etc/$i > /dev/null; then - cfgfile=$(readlink -f -e /etc/$i) - echo $cfgfile - return - fi - done - - for t in /boot/grub/grub.cfg /boot/grub2/grub.cfg; do - if grep -q 'BEGIN' $t 2>/dev/null; then - echo $t - return - fi - done - - echo "xx" -} - -update_grub_config() { - if update-grub -V > /dev/null 2>&1; then - GRUB_UPDATE=update-grub - elif update-grub2 -V > /dev/null 2>&1; then - GRUB_UPDATE=update-grub2 - else - vgrubcfg=$(find_grub_config_path) - mkconfig=$(find_grub_mkconfig_path) - - if [ -f $mkconfig -a -f $vgrubcfg ]; then - GRUB_UPDATE="$mkconfig -o $vgrubcfg" - else - echo "update-grub no need" - return - fi - fi - - UPDATE=0 - - if [ -f /etc/default/grub ]; then - if grep -q 'GRUB_TIMEOUT=0' /etc/default/grub; then - UPDATE=1 - sed 's/GRUB_TIMEOUT=0/GRUB_TIMEOUT=30/' -i /etc/default/grub - fi - - if grep -q 'GRUB_TIMEOUT_STYLE=hidden' /etc/default/grub; then - UPDATE=1 - sed 's/GRUB_TIMEOUT_STYLE=hidden/GRUB_TIMEOUT_STYLE=menu/' -i /etc/default/grub - fi - fi - - if [ $UPDATE -eq 1 ]; then - echo "update grub config" - $GRUB_UPDATE - fi -} - -print_bios_grub_warning() { - echo -e "\033[33m[WARNING] ################################################################## \033[0m" - for i in 0 1 2 3 4 5 6 7 8 9; do - echo -e "\033[33m[WARNING] !!!! This vhd/vdi/raw file will only be bootable in UEFI mode !!!! \033[0m" - done - echo -e "\033[33m[WARNING] ################################################################## \033[0m" - sleep 3 -} - -install_legacy_bios_grub() { - all_modules="" - - if [ -f /boot/grub/grub.cfg ]; then - PREFIX=/boot/grub - MOD_PATH=/boot/grub - CFG=grub.cfg - - if [ -f /boot/efi/EFI/UOS/grub.cfg ]; then - PREFIX=/EFI/UOS - elif [ -f /boot/efi/EFI/ubuntu/grub.cfg ]; then - PREFIX=/EFI/ubuntu - fi - else - for i in grub.cfg grub2.cfg grub-efi.cfg grub2-efi.cfg; do - if readlink -f -e /etc/$i > /dev/null; then - cfgfile=$(readlink -f -e /etc/$i) - MOD_PATH=${cfgfile%/*} - - PREFIX=$MOD_PATH - if echo $MOD_PATH | grep -q '^/boot/efi'; then - if mountpoint -q /boot/efi; then - PREFIX=${MOD_PATH#/boot/efi} - fi - fi - - CFG=${cfgfile##*/} - echo "/etc/$i --> $cfgfile" - break - fi - done - - if [ -z "$MOD_PATH" ]; then - if [ -f /boot/grub2/grub.cfg ]; then - PREFIX=/boot/grub2 - MOD_PATH=/boot/grub2 - CFG=grub.cfg - - if [ -f /boot/efi/EFI/opensuse/grub.cfg ]; then - PREFIX=/EFI/opensuse - fi - fi - - - fi - - if [ -z "$MOD_PATH" ]; then - echo "[WARNING] grub.cfg not found, this vhd/vdi/raw file can only be booted in UEFI mode." - print_bios_grub_warning - return - fi - fi - - if grub-mkimage -V > /dev/null 2>&1; then - GRUB_CMD=grub-mkimage - CFG_CMD=grub-mkconfig - elif grub2-mkimage -V > /dev/null 2>&1; then - GRUB_CMD=grub2-mkimage - CFG_CMD=grub2-mkconfig - else - echo "[WARNING] grub-mkimage not found, package missing?" - print_bios_grub_warning - return - fi - - if [ -d /usr/lib/grub/x86_64-efi ]; then - GRUB_DIR=/usr/lib/grub - elif [ -d /usr/lib/grub/i386-pc ]; then - GRUB_DIR=/usr/lib/grub - elif [ -d /usr/share/grub2/i386-pc ]; then - GRUB_DIR=/usr/share/grub2 - else - echo "[WARNING] grub module directory not found, package missing?" - print_bios_grub_warning - return - fi - - if ! [ -d $GRUB_DIR/i386-pc ]; then - echo "[WARNING] grub i386-pc modules not installed, package missing?" - print_bios_grub_warning - return - fi - - if [ -e /dev/sda ]; then - DISK=/dev/sda - elif [ -e /dev/vda ]; then - DISK=/dev/vda - elif [ -e /dev/hda ]; then - DISK=/dev/hda - else - echo "[WARNING] disk not found" - print_bios_grub_warning - return - fi - - if $vtcheckcmd $DISK; then - echo "GPT check $DISK OK ..." - else - echo "GPT check $DISK failed, code=$?" - return - fi - - echo PREFIX=$PREFIX CFG=$CFG DISK=$DISK - echo MOD_PATH=$MOD_PATH - - chkPrefix=$PREFIX - while [ -n "$chkPrefix" ]; do - if mountpoint -q "$chkPrefix"; then - PREFIX=${MOD_PATH#$chkPrefix} - echo "$chkPrefix is mountpoint PREFIX=$PREFIX" - break - fi - chkPrefix=${chkPrefix%/*} - done - - if grep -q 'linuxefi' $MOD_PATH/$CFG; then - echo "update grub.cfg ..." - cp -a ./tools/01_linuxefi /etc/grub.d/ - $CFG_CMD -o $MOD_PATH/$CFG - elif grep -q 'blscfg' $MOD_PATH/$CFG; then - echo "update grub.cfg disable bls ..." - - if grep -q '^GRUB_ENABLE_BLSCFG' /etc/default/grub; then - sed 's/^GRUB_ENABLE_BLSCFG.*/GRUB_ENABLE_BLSCFG=false/g' -i /etc/default/grub - else - echo 'GRUB_ENABLE_BLSCFG=false' >> /etc/default/grub - fi - $CFG_CMD -o $MOD_PATH/$CFG - fi - - cp -a ./tools/embedcfg embed.cfg - sed "s#XXX#$PREFIX#g" -i embed.cfg - sed "s#YYY#$CFG#g" -i embed.cfg - - for mod in $(cat ./tools/grubmodules); do - if [ -e $GRUB_DIR/i386-pc/${mod}.mod ]; then - all_modules="$all_modules $mod" - fi - done - - $GRUB_CMD -c "./embed.cfg" --prefix "$PREFIX" --output "./core.img" --format 'i386-pc' --compression 'auto' $all_modules - - echo "Write loader to $DISK ..." - dd if=$GRUB_DIR/i386-pc/boot.img of=$DISK bs=1 count=440 status=none && sync - dd if=./tools/bootbin of=/dev/sda bs=1 count=1 seek=92 status=none && sync - dd if=./core.img of=/dev/sda bs=512 seek=34 status=none && sync - dd if=./tools/bootbin of=/dev/sda bs=1 count=1 skip=1 seek=17908 status=none && sync - - if ! [ -d $MOD_PATH/i386-pc ]; then - cp -a $GRUB_DIR/i386-pc $MOD_PATH/ - fi - - rm -f ./embed.cfg - rm -f ./core.img -} - -wrapper_grub_probe() { - if [ -e "${1}-bk" ]; then - if grep -q '#!' "$1"; then - rm -f "$1" - mv "${1}-bk" "$1" - else - rm -f "${1}-bk" - fi - fi - - cp -a "$1" "${1}-bk" - rm -f "$1" - cp -a ./tools/grub-probe.sh "$1" - - chmod +x "$1" - chmod +x "${1}-bk" -} - -replace_shim_efi() { - echo "replace shim efi ..." - if [ ! -d /boot/efi/EFI ]; then - return - fi - - vCnt=$(find /boot/efi/EFI -type f | grep -i /efi/boot/bootx64.efi | wc -l) - if [ $vCnt -ne 1 ]; then - echo "bootx64.efi no need $vCnt" - return - fi - vBOOTX64=$(find /boot/efi/EFI -type f | grep -i /efi/boot/bootx64.efi) - - vCnt=$(find /boot/efi/EFI -type f | grep -i shimx64.efi | wc -l) - if [ $vCnt -ne 1 ]; then - echo "shimx64.efi no need $vCnt" - return - fi - vSHIMX64=$(find /boot/efi/EFI -type f | grep -i shimx64.efi) - - vCnt=$(find /boot/efi/EFI -type f | grep -i grubx64.efi | wc -l) - if [ $vCnt -ne 1 ]; then - echo "grubx64.efi no need $vCnt" - return - fi - vGRUBX64=$(find /boot/efi/EFI -type f | grep -i grubx64.efi) - - vMD51=$(md5sum $vBOOTX64 | awk '{print $1}') - vMD52=$(md5sum $vSHIMX64 | awk '{print $1}') - if [ "$vMD51" != "$vMD52" ]; then - echo "bootx64 shimx64 not equal" - echo "$vMD51" - echo "$vMD52" - return - fi - - echo "BOOT=$vBOOTX64" - echo "GRUB=$vGRUBX64" - mv $vBOOTX64 ${vBOOTX64}_VTBK - cp $vGRUBX64 $vBOOTX64 -} - -recover_shim_efi() { - echo "recover shim efi ..." - if [ ! -d /boot/efi/EFI ]; then - return - fi - - vVTBKFILE=$(find /boot/efi/EFI -type f | grep -i '_VTBK$') - if [ -z "$vVTBKFILE" ]; then - echo "no backup file found, no need." - return - fi - - if [ -f "$vVTBKFILE" ]; then - vVTRAWFILE=$(echo "$vVTBKFILE" | sed "s/_VTBK//") - if [ -f "$vVTRAWFILE" ]; then - rm -f "$vVTRAWFILE" - echo "BACK=$vVTRAWFILE" - echo "BOOT=$vVTBKFILE" - mv "$vVTBKFILE" "$vVTRAWFILE" - fi - fi -} diff --git a/vtoyboot/tools/embedcfg b/vtoyboot/tools/embedcfg deleted file mode 100644 index 9ec5294..0000000 --- a/vtoyboot/tools/embedcfg +++ /dev/null @@ -1,3 +0,0 @@ -search -f XXX/YYY -s root -set prefix=($root)XXX -configfile $prefix/YYY diff --git a/vtoyboot/tools/grub-probe.sh b/vtoyboot/tools/grub-probe.sh deleted file mode 100644 index 4547fbc..0000000 --- a/vtoyboot/tools/grub-probe.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh - -if which grub-probe-bk >/dev/null 2>&1; then - grub_probe_cmd=grub-probe-bk -elif which grub2-probe-bk >/dev/null 2>&1; then - grub_probe_cmd=grub2-probe-bk -else - grub_probe_cmd=grub-probe-bk -fi - -curdate=$(date) -if [ -e /dev/mapper/ventoy -a -d /etc/vtoyboot/probe ]; then - $grub_probe_cmd $* > /etc/vtoyboot/probe/tmp_stdout 2>/etc/vtoyboot/probe/tmp_stderr - code=$? - if [ $code -eq 0 ]; then - cat /etc/vtoyboot/probe/tmp_stdout - exit 0 - fi - - newpara=$(echo $* | sed "s#/dev/mapper/ventoy#/dev/sda#") - echo "[$curdate] oldpara=$* newpara=$newpara" >> /etc/vtoyboot/probe/match.log - - id=1 - while [ -n "1" ]; do - if [ -d /etc/vtoyboot/probe/$id ]; then - para=$(head -n1 /etc/vtoyboot/probe/$id/param) - if [ "$para" = "$newpara" ]; then - code=$(cat /etc/vtoyboot/probe/$id/errcode) - cat /etc/vtoyboot/probe/$id/stdout - if [ $code -ne 0 ]; then - cat /etc/vtoyboot/probe/$id/stderr >&2 - fi - - echo "[$curdate] grub-probe match history id=$id code=$code" >> /etc/vtoyboot/probe/match.log - exit $code - fi - else - break - fi - id=$(expr $id + 1) - done - - echo "[$curdate] grub-probe NO match $*" >> /etc/vtoyboot/probe/match.log - cat /etc/vtoyboot/probe/tmp_stdout - cat /etc/vtoyboot/probe/tmp_stderr >&2 - exit $code -else - [ -d /etc/vtoyboot/probe ] || mkdir -p /etc/vtoyboot/probe - - id=1 - override=0 - while [ -d /etc/vtoyboot/probe/$id ]; do - para=$(head -n1 /etc/vtoyboot/probe/$id/param) - if [ "$para" = "$*" ]; then - echo "[$curdate] override $id $*" >> /etc/vtoyboot/probe/history.log - override=1 - break - fi - id=$(expr $id + 1) - done - - if [ $override -eq 0 ]; then - echo "[$curdate] $*" >> /etc/vtoyboot/probe/history.log - fi - - mkdir -p /etc/vtoyboot/probe/$id - echo "$*" > /etc/vtoyboot/probe/$id/param - $grub_probe_cmd $* > /etc/vtoyboot/probe/$id/stdout 2>/etc/vtoyboot/probe/$id/stderr - code=$? - echo $code > /etc/vtoyboot/probe/$id/errcode - - cat /etc/vtoyboot/probe/$id/stdout - cat /etc/vtoyboot/probe/$id/stderr >&2 - exit $code -fi - diff --git a/vtoyboot/tools/grubmodules b/vtoyboot/tools/grubmodules deleted file mode 100644 index 1431446..0000000 --- a/vtoyboot/tools/grubmodules +++ /dev/null @@ -1,78 +0,0 @@ -loadenv -lvm -diskfilter -date -drivemap -blocklist -regexp -newc -vga_text -ntldr -search -at_keyboard -usb_keyboard -gcry_md5 -hashsum -gzio -xzio -lzopio -lspci -pci -ext2 -xfs -chain -read -halt -iso9660 -linux16 -test -true -sleep -reboot -echo -videotest -videoinfo -videotest_checksum -video_colors -video_cirrus -video_bochs -vga -vbe -video_fb -font -video -gettext -extcmd -terminal -linux -minicmd -help -configfile -tr -trig -boot -biosdisk -disk -ls -tar -squash4 -password_pbkdf2 -all_video -png -jpeg -part_gpt -part_msdos -fat -exfat -ntfs -loopback -gzio -normal -udf -gfxmenu -gfxterm -gfxterm_background -gfxterm_menu -net -tftp -http \ No newline at end of file diff --git a/vtoyboot/tools/vtoycheck32 b/vtoyboot/tools/vtoycheck32 deleted file mode 100644 index 166b657..0000000 Binary files a/vtoyboot/tools/vtoycheck32 and /dev/null differ diff --git a/vtoyboot/tools/vtoycheck64 b/vtoyboot/tools/vtoycheck64 deleted file mode 100644 index 374d3f2..0000000 Binary files a/vtoyboot/tools/vtoycheck64 and /dev/null differ diff --git a/vtoyboot/tools/vtoycheckaa64 b/vtoyboot/tools/vtoycheckaa64 deleted file mode 100644 index 9cebe23..0000000 Binary files a/vtoyboot/tools/vtoycheckaa64 and /dev/null differ diff --git a/vtoyboot/tools/vtoydrivers b/vtoyboot/tools/vtoydrivers deleted file mode 100644 index 3ab3d1e..0000000 --- a/vtoyboot/tools/vtoydrivers +++ /dev/null @@ -1,28 +0,0 @@ -efivars -efivarfs -mptsas -mptspi -nvme -usb-storage -ehci-fsl -ehci-hcd -ehci-pci -ehci-platform -ohci-hcd -ohci-pci -ohci-platform -uhci-hcd -xhci-hcd -xhci-pci -xhci-plat-hcd -vhci-hcd -usbhid -sg -uas -pmcraid -smartpqi -megaraid -megaraid_sas -vmw_pvscsi -mvsas -aacraid diff --git a/vtoyboot/tools/vtoydump32 b/vtoyboot/tools/vtoydump32 deleted file mode 100644 index b066c29..0000000 Binary files a/vtoyboot/tools/vtoydump32 and /dev/null differ diff --git a/vtoyboot/tools/vtoydump64 b/vtoyboot/tools/vtoydump64 deleted file mode 100644 index 0f17a61..0000000 Binary files a/vtoyboot/tools/vtoydump64 and /dev/null differ diff --git a/vtoyboot/tools/vtoydumpaa64 b/vtoyboot/tools/vtoydumpaa64 deleted file mode 100644 index 06fd2d8..0000000 Binary files a/vtoyboot/tools/vtoydumpaa64 and /dev/null differ diff --git a/vtoyboot/tools/vtoygrub b/vtoyboot/tools/vtoygrub deleted file mode 100644 index 843ec59..0000000 --- a/vtoyboot/tools/vtoygrub +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh - -find_grub_probe_path() { - if which grub-probe >/dev/null 2>&1; then - which grub-probe - elif which grub2-probe >/dev/null 2>&1; then - which grub2-probe - else - echo "XXX" - fi -} - -find_grub_mkconfig_path() { - if which grub-mkconfig >/dev/null 2>&1; then - which grub-mkconfig - elif which grub2-mkconfig >/dev/null 2>&1; then - which grub2-mkconfig - else - echo "XXX" - fi -} - -find_grub_config_path() { - for i in grub.cfg grub2.cfg grub-efi.cfg grub2-efi.cfg; do - if readlink -f -e /etc/$i > /dev/null; then - cfgfile=$(readlink -f -e /etc/$i) - echo $cfgfile - return - fi - done - - for t in /boot/grub/grub.cfg /boot/grub2/grub.cfg; do - if grep -q 'BEGIN' $t 2>/dev/null; then - echo $t - return - fi - done - - echo "xx" -} - -update_grub_config() { - GRUB_UPDATE="" - if update-grub -V > /dev/null 2>&1; then - GRUB_UPDATE=update-grub - elif update-grub2 -V > /dev/null 2>&1; then - GRUB_UPDATE=update-grub2 - else - vgrubcfg=$(find_grub_config_path) - mkconfig=$(find_grub_mkconfig_path) - - if [ -f $mkconfig -a -f $vgrubcfg ]; then - GRUB_UPDATE="$mkconfig -o $vgrubcfg" - else - echo "no grub.cfg found." - return - fi - fi - - if [ -n "$GRUB_UPDATE" ]; then - echo "update grub config $GRUB_UPDATE" - $GRUB_UPDATE - fi -} - -USER=$(whoami) -if [ "$USER" != "root" ]; then - echo "Please run this script as root or use sudo" - echo "" - exit 1 -fi - -update_grub_config diff --git a/vtoyboot/tools/vtoypartx32 b/vtoyboot/tools/vtoypartx32 deleted file mode 100644 index 7273eb7..0000000 Binary files a/vtoyboot/tools/vtoypartx32 and /dev/null differ diff --git a/vtoyboot/tools/vtoypartx64 b/vtoyboot/tools/vtoypartx64 deleted file mode 100644 index 4135cd7..0000000 Binary files a/vtoyboot/tools/vtoypartx64 and /dev/null differ diff --git a/vtoyboot/tools/vtoypartxaa64 b/vtoyboot/tools/vtoypartxaa64 deleted file mode 100644 index eac7c87..0000000 Binary files a/vtoyboot/tools/vtoypartxaa64 and /dev/null differ diff --git a/vtoyboot/tools/vtoytool_32 b/vtoyboot/tools/vtoytool_32 deleted file mode 100644 index 2f02486..0000000 Binary files a/vtoyboot/tools/vtoytool_32 and /dev/null differ diff --git a/vtoyboot/tools/vtoytool_64 b/vtoyboot/tools/vtoytool_64 deleted file mode 100644 index 51a0b16..0000000 Binary files a/vtoyboot/tools/vtoytool_64 and /dev/null differ diff --git a/vtoyboot/tools/vtoytool_aa64 b/vtoyboot/tools/vtoytool_aa64 deleted file mode 100644 index 7af30d5..0000000 Binary files a/vtoyboot/tools/vtoytool_aa64 and /dev/null differ diff --git a/vtoyboot/vtoyboot.sh b/vtoyboot/vtoyboot.sh deleted file mode 100644 index d12c5e3..0000000 --- a/vtoyboot/vtoyboot.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh -#************************************************************************************ -# Copyright (c) 2020, longpanda -# -# 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 . -# -#************************************************************************************ - -vtoy_version=1.0.20 - -if echo "$*" | grep -q __vtoyloop__; then - : -else - if readlink /proc/$$/exe | grep -q dash; then - exec /bin/bash $0 $* __vtoyloop__ - fi -fi - -vtoy_get_initrdtool_type() { - . ./distros/initramfstool/check.sh - . ./distros/mkinitcpio/check.sh - . ./distros/dracut/check.sh - - if vtoy_check_initramfs_tool; then - echo 'initramfstool'; return - elif vtoy_check_mkinitcpio; then - echo 'mkinitcpio'; return - elif vtoy_check_dracut; then - echo 'dracut'; return - else - echo 'unknown'; return - fi -} - -echo '' -echo '**********************************************' -echo " vtoyboot $vtoy_version" -echo " longpanda admin@ventoy.net" -echo " https://www.ventoy.net" -echo '**********************************************' -echo '' - -USER=$(whoami) -if [ "$USER" != "root" ]; then - echo "Please run this script as root or use sudo" - echo "" - exit 1 -fi - -if ! [ -d ./distros ]; then - echo "Please run the script in the right directory" - echo "" - exit 1 -fi - -if [ -e /dev/mapper/ventoy ]; then - : -else - if ls -1 /dev | grep -q '[svh]db$'; then - echo "More than one disks found. Currently only one disk is supported." - echo "" - exit 1 - fi -fi - -initrdtool=$(vtoy_get_initrdtool_type) - -if ! [ -f ./distros/$initrdtool/vtoy.sh ]; then - echo 'Current OS is not supported!' - exit 1 -fi - - -#prepare vtoydump -if uname -a | grep -Eq "x86_64|amd64"; then - vtdumpcmd=./tools/vtoydump64 - partxcmd=./tools/vtoypartx64 - vtcheckcmd=./tools/vtoycheck64 - vtoytool=./tools/vtoytool_64 - dmpatchko=./tools/dm_patch_64.ko -elif uname -a | grep -Eq "aarch64|arm64"; then - vtdumpcmd=./tools/vtoydumpaa64 - partxcmd=./tools/vtoypartxaa64 - vtcheckcmd=./tools/vtoycheckaa64 - vtoytool=./tools/vtoytool_aa64 - dmpatchko=./tools/dm_patch_64.ko -else - vtdumpcmd=./tools/vtoydump32 - partxcmd=./tools/vtoypartx32 - vtcheckcmd=./tools/vtoycheck32 - vtoytool=./tools/vtoytool_32 - dmpatchko=./tools/dm_patch_32.ko -fi - -chmod +x $vtdumpcmd $partxcmd $vtcheckcmd - -for vsh in $(ls ./distros/$initrdtool/*.sh); do - chmod +x $vsh -done - -echo "Current system use $initrdtool as initramfs tool" -. ./distros/$initrdtool/vtoy.sh "$@" -if [ $? -eq 0 ]; then - sync - echo "" - echo "vtoyboot process successfully finished." - echo "" -else - echo "" - echo "vtoyboot process failed, please check." - echo "" - exit 1 -fi