mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-08-28 00:11:15 +00:00
1. Boot menu over serial supported
2. Optimization for booting Solus 3. Optimization for booting .efi file 4. support deepin-live iso 5. support Endless OS 6. framework for booting .img file
This commit is contained in:
@@ -54,7 +54,8 @@ if [ -z "$VTOY_REDT_BUG" ]; then
|
||||
fi
|
||||
|
||||
cd $VTOY_PATH
|
||||
xz -d ventoy.sh.xz
|
||||
xz -d ventoy_chain.sh.xz
|
||||
xz -d ventoy_loop.sh.xz
|
||||
|
||||
if [ -n "$VTOY_REDT_BUG" ]; then
|
||||
xz -d -c hook.cpio.xz | cpio -idm
|
||||
|
150
IMG/cpio/ventoy/hook/default/10-dm.rules
Normal file
150
IMG/cpio/ventoy/hook/default/10-dm.rules
Normal file
@@ -0,0 +1,150 @@
|
||||
# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
|
||||
# Udev rules for device-mapper devices.
|
||||
#
|
||||
# These rules create a DM control node in /dev/mapper directory.
|
||||
# The rules also create nodes named dm-x (x is a number) in /dev
|
||||
# directory and symlinks to these nodes with names given by
|
||||
# the actual DM names. Some udev environment variables are set
|
||||
# for use in later rules:
|
||||
# DM_NAME - actual DM device's name
|
||||
# DM_UUID - UUID set for DM device (blank if not specified)
|
||||
# DM_SUSPENDED - suspended state of DM device (0 or 1)
|
||||
# DM_UDEV_RULES_VSN - DM udev rules version
|
||||
#
|
||||
# These rules cover only basic device-mapper functionality in udev.
|
||||
#
|
||||
# Various DM subsystems may contain further subsystem-specific rules
|
||||
# in 11-dm-<subsystem_name>.rules which should be installed together
|
||||
# with the DM subsystem and which extend these basic rules.
|
||||
# For example:
|
||||
# 11-dm-lvm.rules for LVM subsystem
|
||||
# 11-dm-mpath.rules for multipath subsystem (since version 0.6.0, recommended!)
|
||||
#
|
||||
# Even more specific rules may be required by subsystems so always
|
||||
# check subsystem's upstream repository for recent set of rules.
|
||||
# Also, keep in mind that recent rules may also require recent
|
||||
# subsystem-specific binaries.
|
||||
|
||||
KERNEL=="device-mapper", NAME="mapper/control"
|
||||
|
||||
SUBSYSTEM!="block", GOTO="dm_end"
|
||||
KERNEL!="dm-[0-9]*", GOTO="dm_end"
|
||||
|
||||
|
||||
# Device created, major and minor number assigned - "add" event generated.
|
||||
# Table loaded - no event generated.
|
||||
# Device resumed (or renamed) - "change" event generated.
|
||||
# Device removed - "remove" event generated.
|
||||
#
|
||||
# The dm-X nodes are always created, even on "add" event, we can't suppress
|
||||
# that (the node is created even earlier with devtmpfs). All the symlinks
|
||||
# (e.g. /dev/mapper) are created in right time after a device has its table
|
||||
# loaded and is properly resumed. For this reason, direct use of dm-X nodes
|
||||
# is not recommended.
|
||||
ACTION!="add|change", GOTO="dm_end"
|
||||
|
||||
# Decode udev control flags and set environment variables appropriately.
|
||||
# These flags are encoded in DM_COOKIE variable that was introduced in
|
||||
# kernel version 2.6.31. Therefore, we can use this feature with
|
||||
# kernels >= 2.6.31 only. Cookie is not decoded for remove event.
|
||||
ENV{DM_COOKIE}=="?*", IMPORT{program}="/usr/sbin/dmsetup udevflags $env{DM_COOKIE}"
|
||||
|
||||
# Rule out easy-to-detect inappropriate events first.
|
||||
ENV{DISK_RO}=="1", GOTO="dm_disable"
|
||||
|
||||
# There is no cookie set nor any flags encoded in events not originating
|
||||
# in libdevmapper so we need to detect this and try to behave correctly.
|
||||
# For such spurious events, regenerate all flags from current udev database content
|
||||
# (this information would normally be inaccessible for spurious ADD and CHANGE events).
|
||||
ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}="1", GOTO="dm_flags_done"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_DM_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_DISK_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_OTHER_RULES_FLAG"
|
||||
IMPORT{db}="DM_UDEV_LOW_PRIORITY_FLAG"
|
||||
IMPORT{db}="DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG"
|
||||
IMPORT{db}="DM_UDEV_PRIMARY_SOURCE_FLAG"
|
||||
IMPORT{db}="DM_UDEV_FLAG7"
|
||||
IMPORT{db}="DM_UDEV_RULES_VSN"
|
||||
LABEL="dm_flags_done"
|
||||
|
||||
# Normally, we operate on "change" events. But when coldplugging, there's an
|
||||
# "add" event present. We have to recognize this and do our actions in this
|
||||
# particular situation, too. Also, we don't want the nodes to be created
|
||||
# prematurely on "add" events while not coldplugging. We check
|
||||
# DM_UDEV_PRIMARY_SOURCE_FLAG to see if the device was activated correctly
|
||||
# before and if not, we ignore the "add" event totally. This way we can support
|
||||
# udev triggers generating "add" events (e.g. "udevadm trigger --action=add" or
|
||||
# "echo add > /sys/block/<dm_device>/uevent"). The trigger with "add" event is
|
||||
# also used at boot to reevaluate udev rules for all existing devices activated
|
||||
# before (e.g. in initrd). If udev is used in initrd, we require the udev init
|
||||
# script to not remove the existing udev database so we can reuse the information
|
||||
# stored at the time of device activation in the initrd.
|
||||
ACTION!="add", GOTO="dm_no_coldplug"
|
||||
ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="dm_disable"
|
||||
ENV{DM_ACTIVATION}="1"
|
||||
LABEL="dm_no_coldplug"
|
||||
|
||||
# Putting it together, following table is used to recognize genuine and spurious events.
|
||||
# N.B. Spurious events are generated based on use of the WATCH udev
|
||||
# rule or by triggering an event manually by "udevadm trigger" call
|
||||
# or by "echo <event_name> > /sys/block/dm-X/uevent".
|
||||
#
|
||||
# EVENT DM_UDEV_PRIMARY_SOURCE_FLAG DM_ACTIVATION
|
||||
# ======================================================================
|
||||
# add event (genuine) 0 0
|
||||
# change event (genuine) 1 1
|
||||
# add event (spurious)
|
||||
# |_ dev still not active 0 0
|
||||
# \_ dev already active 1 1
|
||||
# change event (spurious)
|
||||
# |_ dev still not active 0 0
|
||||
# \_ dev already active 1 0
|
||||
|
||||
# "dm" sysfs subdirectory is available in newer versions of DM
|
||||
# only (kernels >= 2.6.29). We have to check for its existence
|
||||
# and use dmsetup tool instead to get the DM name, uuid and
|
||||
# suspended state if the "dm" subdirectory is not present.
|
||||
# The "suspended" item was added even later (kernels >= 2.6.31),
|
||||
# so we also have to call dmsetup if the kernel version used
|
||||
# is in between these releases.
|
||||
TEST=="dm", ENV{DM_NAME}="$attr{dm/name}", ENV{DM_UUID}="$attr{dm/uuid}", ENV{DM_SUSPENDED}="$attr{dm/suspended}"
|
||||
TEST!="dm", IMPORT{program}="/usr/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended"
|
||||
ENV{DM_SUSPENDED}!="?*", IMPORT{program}="/usr/sbin/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended"
|
||||
|
||||
# dmsetup tool provides suspended state information in textual
|
||||
# form with values "Suspended"/"Active". We translate it to
|
||||
# 0/1 respectively to be consistent with sysfs values.
|
||||
ENV{DM_SUSPENDED}=="Active", ENV{DM_SUSPENDED}="0"
|
||||
ENV{DM_SUSPENDED}=="Suspended", ENV{DM_SUSPENDED}="1"
|
||||
|
||||
# This variable provides a reliable way to check that device-mapper
|
||||
# rules were installed. It means that all needed variables are set
|
||||
# by these rules directly so there's no need to acquire them again
|
||||
# later. Other rules can alternate the functionality based on this
|
||||
# fact (e.g. fallback to rules that behave correctly even without
|
||||
# these rules installed). It also provides versioning for any
|
||||
# possible future changes.
|
||||
# VSN 1 - original rules
|
||||
# VSN 2 - add support for synthesized events
|
||||
ENV{DM_UDEV_RULES_VSN}="2"
|
||||
|
||||
ENV{DM_UDEV_DISABLE_DM_RULES_FLAG}!="1", ENV{DM_NAME}=="?*", SYMLINK+="mapper/$env{DM_NAME}"
|
||||
|
||||
# Avoid processing and scanning a DM device in the other (foreign)
|
||||
# rules if it is in suspended state. However, we still keep 'disk'
|
||||
# and 'DM subsystem' related rules enabled in this case.
|
||||
ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
|
||||
|
||||
GOTO="dm_end"
|
||||
|
||||
LABEL="dm_disable"
|
||||
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}="1"
|
||||
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
|
||||
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
|
||||
OPTIONS:="nowatch"
|
||||
|
||||
LABEL="dm_end"
|
@@ -475,7 +475,7 @@ ventoy_udev_disk_common_hook() {
|
||||
|
||||
|
||||
is_inotify_ventoy_part() {
|
||||
if echo $1 | grep -q "2$"; then
|
||||
if echo $1 | $GREP -q "2$"; then
|
||||
if ! [ -e /sys/block/$1 ]; then
|
||||
if [ -e /sys/class/block/$1 ]; then
|
||||
if [ -e /dev/${1:0:-1} ]; then
|
||||
|
@@ -105,3 +105,9 @@ ventoy_print_yum_repo() {
|
||||
ventoy_set_inotify_script() {
|
||||
echo $VTOY_PATH/hook/$1 > $VTOY_PATH/inotifyd-hook-script.txt
|
||||
}
|
||||
|
||||
ventoy_set_loop_inotify_script() {
|
||||
echo $VTOY_PATH/loop/$1 > $VTOY_PATH/inotifyd-loop-script.txt
|
||||
}
|
||||
|
||||
|
||||
|
@@ -24,203 +24,14 @@
|
||||
# #
|
||||
####################################################################
|
||||
[ -d /proc ] || mkdir /proc; mount -t proc proc /proc
|
||||
vtcmdline=$(cat /proc/cmdline)
|
||||
vtkerver=$(cat /proc/version)
|
||||
vtoy_cmdline=$(cat /proc/cmdline)
|
||||
umount /proc; rm -rf /proc
|
||||
|
||||
echo "kenel version=$vtkerver" >>$VTLOG
|
||||
echo "kenel cmdline=$vtcmdline" >>$VTLOG
|
||||
|
||||
#break here for debug
|
||||
if [ "$VTOY_BREAK_LEVEL" = "01" ] || [ "$VTOY_BREAK_LEVEL" = "11" ]; then
|
||||
sleep 5
|
||||
echo -e "\n\n\033[32m ################################################# \033[0m"
|
||||
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
|
||||
echo -e "\033[32m ################################################# \033[0m \n"
|
||||
|
||||
if [ "$VTOY_BREAK_LEVEL" = "11" ]; then
|
||||
cat $VTLOG
|
||||
fi
|
||||
exec $BUSYBOX_PATH/sh
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 2 : extract real initramfs to / #
|
||||
# #
|
||||
####################################################################
|
||||
cd /
|
||||
rm -rf /init /linuxrc /dev/ /root
|
||||
|
||||
vtSbinFileNum=$(ls -1 /sbin | wc -l)
|
||||
if [ $vtSbinFileNum -eq 1 ]; then
|
||||
echo "remove whole sbin directory" >> $VTLOG
|
||||
rm -rf /sbin
|
||||
if echo $vtoy_cmdline | grep -q 'rdinit=/vtoy/vtoy'; then
|
||||
echo "handover to init_loop" >>$VTLOG
|
||||
rm -f /xxxx /vtoyxrc
|
||||
exec $BUSYBOX_PATH/sh $VTOY_PATH/init_loop
|
||||
else
|
||||
echo "remove only sbin/init file" >> $VTLOG
|
||||
ls -l /sbin >> $VTLOG
|
||||
rm -f /sbin/init
|
||||
echo "handover to init_chain" >>$VTLOG
|
||||
exec $BUSYBOX_PATH/sh $VTOY_PATH/init_chain
|
||||
fi
|
||||
|
||||
ventoy_is_initrd_ramdisk() {
|
||||
#As I known, PCLinuxOS use ramdisk
|
||||
if echo $vtkerver | grep -i -q 'PCLinuxOS'; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_mount_squashfs() {
|
||||
mkdir /dev
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
dd if=$1 of=/dev/ram0 status=none
|
||||
umount /dev && rm -rf /dev
|
||||
}
|
||||
|
||||
# param: file skip magic tmp
|
||||
ventoy_unpack_initramfs() {
|
||||
vtfile=$1; vtskip=$2; vtmagic=$3; vttmp=$4
|
||||
echo "=====ventoy_unpack_initramfs: #$*#" >> $VTLOG
|
||||
|
||||
#special process
|
||||
#if [ "${vtmagic:0:4}" = '5678' ]; then
|
||||
# echo -en '\x1F\x8B' | dd status=none of=$vtfile bs=1 count=2 conv=notrunc
|
||||
# vtmagic='1F8B'
|
||||
#fi
|
||||
|
||||
if [ "${vtmagic:0:4}" = '6873' ]; then
|
||||
ventoy_mount_squashfs $vtfile
|
||||
return
|
||||
fi
|
||||
|
||||
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat'; do
|
||||
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
|
||||
echo "vtx=$vtx" >> $VTLOG
|
||||
if [ $vtskip -eq 0 ]; then
|
||||
if [ "${vtx:5}" = "xzcat" ]; then
|
||||
rm -f $VTOY_PATH/xzlog
|
||||
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
|
||||
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
|
||||
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
|
||||
cat $vtfile | xzminidec | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
fi
|
||||
|
||||
else
|
||||
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
fi
|
||||
else
|
||||
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# param: file magic tmp
|
||||
ventoy_unpack_initrd() {
|
||||
vtfile=$1; vtmagic=$2; vttmp=$3
|
||||
echo "=====ventoy_unpack_initrd: #$*#" >> $VTLOG
|
||||
|
||||
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat'; do
|
||||
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
|
||||
echo "vtx=$vtx" >> $VTLOG
|
||||
${vtx:5} $vtfile > $vttmp
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# This export is for busybox cpio command
|
||||
export EXTRACT_UNSAFE_SYMLINKS=1
|
||||
|
||||
for vtfile in $(ls /initrd*); do
|
||||
#decompress first initrd
|
||||
vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $vtfile)
|
||||
|
||||
if ventoy_is_initrd_ramdisk; then
|
||||
ventoy_unpack_initrd $vtfile $vtmagic ${vtfile}_tmp
|
||||
mv ${vtfile}_tmp $vtfile
|
||||
break
|
||||
else
|
||||
ventoy_unpack_initramfs $vtfile 0 $vtmagic ${vtfile}_tmp
|
||||
fi
|
||||
|
||||
#only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported
|
||||
while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do
|
||||
mv ${vtfile}_tmp $vtfile
|
||||
vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile)
|
||||
vtmagic=$(echo $vtdump | sed 's/^\(00\)*//')
|
||||
let vtoffset="(${#vtdump}-${#vtmagic})/2"
|
||||
|
||||
if [ -z "$vtmagic" ]; then
|
||||
echo "terminate with all zero data file" >> $VTLOG
|
||||
break
|
||||
fi
|
||||
|
||||
ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp
|
||||
done
|
||||
|
||||
rm -f $vtfile ${vtfile}_tmp
|
||||
done
|
||||
|
||||
|
||||
#break here for debug
|
||||
if [ "$VTOY_BREAK_LEVEL" = "02" ] || [ "$VTOY_BREAK_LEVEL" = "12" ]; then
|
||||
sleep 5
|
||||
echo -e "\n\n\033[32m ################################################# \033[0m"
|
||||
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
|
||||
echo -e "\033[32m ################################################# \033[0m \n"
|
||||
if [ "$VTOY_BREAK_LEVEL" = "12" ]; then
|
||||
cat $VTOY_PATH/log
|
||||
fi
|
||||
exec $BUSYBOX_PATH/sh
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 3 : Extract injection archive #
|
||||
# #
|
||||
####################################################################
|
||||
ventoy_unpack_injection() {
|
||||
vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $VTOY_PATH/ventoy_injection)
|
||||
echo "ventoy_unpack_injection vtmagic=$vtmagic ..."
|
||||
|
||||
if [ "1F8B" = "$vtmagic" ] || [ "1F9E" = "$vtmagic" ]; then
|
||||
echo "tar.gz tar -xzvf"
|
||||
tar -xzvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "425A" = "$vtmagic" ]; then
|
||||
echo "tar.bz2 tar -xjvf"
|
||||
tar -xjvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "FD37" = "$vtmagic" ]; then
|
||||
echo "tar.xz tar -xJvf"
|
||||
tar -xJvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "5D00" = "$vtmagic" ]; then
|
||||
echo "tar.lzma tar -xavf"
|
||||
tar -xavf $VTOY_PATH/ventoy_injection -C /
|
||||
else
|
||||
echo "unzip -o"
|
||||
unzip -o $VTOY_PATH/ventoy_injection -d /
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -e $VTOY_PATH/ventoy_injection ]; then
|
||||
echo "### decompress injection ... ###" >>$VTLOG
|
||||
ventoy_unpack_injection > $VTOY_PATH/injection.log 2>&1
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 4 : Hand over to ventoy.sh #
|
||||
# #
|
||||
####################################################################
|
||||
echo "Now hand over to ventoy.sh" >>$VTLOG
|
||||
. $VTOY_PATH/tool/vtoytool_install.sh
|
||||
|
||||
export PATH=$VTOY_ORG_PATH
|
||||
exec $BUSYBOX_PATH/sh $VTOY_PATH/ventoy.sh
|
||||
|
226
IMG/cpio/ventoy/init_chain
Normal file
226
IMG/cpio/ventoy/init_chain
Normal file
@@ -0,0 +1,226 @@
|
||||
#!/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/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
|
||||
###################################################################
|
||||
# #
|
||||
# Step 1 : parse kernel debug parameter #
|
||||
# #
|
||||
####################################################################
|
||||
[ -d /proc ] || mkdir /proc; mount -t proc proc /proc
|
||||
vtcmdline=$(cat /proc/cmdline)
|
||||
vtkerver=$(cat /proc/version)
|
||||
umount /proc; rm -rf /proc
|
||||
|
||||
echo "kenel version=$vtkerver" >>$VTLOG
|
||||
echo "kenel cmdline=$vtcmdline" >>$VTLOG
|
||||
|
||||
#break here for debug
|
||||
if [ "$VTOY_BREAK_LEVEL" = "01" ] || [ "$VTOY_BREAK_LEVEL" = "11" ]; then
|
||||
sleep 5
|
||||
echo -e "\n\n\033[32m ################################################# \033[0m"
|
||||
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
|
||||
echo -e "\033[32m ################################################# \033[0m \n"
|
||||
|
||||
if [ "$VTOY_BREAK_LEVEL" = "11" ]; then
|
||||
cat $VTLOG
|
||||
fi
|
||||
exec $BUSYBOX_PATH/sh
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 2 : extract real initramfs to / #
|
||||
# #
|
||||
####################################################################
|
||||
cd /
|
||||
rm -rf /init /linuxrc /dev/ /root
|
||||
|
||||
vtSbinFileNum=$(ls -1 /sbin | wc -l)
|
||||
if [ $vtSbinFileNum -eq 1 ]; then
|
||||
echo "remove whole sbin directory" >> $VTLOG
|
||||
rm -rf /sbin
|
||||
else
|
||||
echo "remove only sbin/init file" >> $VTLOG
|
||||
ls -l /sbin >> $VTLOG
|
||||
rm -f /sbin/init
|
||||
fi
|
||||
|
||||
ventoy_is_initrd_ramdisk() {
|
||||
#As I known, PCLinuxOS use ramdisk
|
||||
if echo $vtkerver | grep -i -q 'PCLinuxOS'; then
|
||||
true
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
ventoy_mount_squashfs() {
|
||||
mkdir /dev
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
dd if=$1 of=/dev/ram0 status=none
|
||||
umount /dev && rm -rf /dev
|
||||
}
|
||||
|
||||
# param: file skip magic tmp
|
||||
ventoy_unpack_initramfs() {
|
||||
vtfile=$1; vtskip=$2; vtmagic=$3; vttmp=$4
|
||||
echo "=====ventoy_unpack_initramfs: #$*#" >> $VTLOG
|
||||
|
||||
#special process
|
||||
#if [ "${vtmagic:0:4}" = '5678' ]; then
|
||||
# echo -en '\x1F\x8B' | dd status=none of=$vtfile bs=1 count=2 conv=notrunc
|
||||
# vtmagic='1F8B'
|
||||
#fi
|
||||
|
||||
if [ "${vtmagic:0:4}" = '6873' ]; then
|
||||
ventoy_mount_squashfs $vtfile
|
||||
return
|
||||
fi
|
||||
|
||||
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat'; do
|
||||
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
|
||||
echo "vtx=$vtx" >> $VTLOG
|
||||
if [ $vtskip -eq 0 ]; then
|
||||
if [ "${vtx:5}" = "xzcat" ]; then
|
||||
rm -f $VTOY_PATH/xzlog
|
||||
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
|
||||
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
|
||||
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
|
||||
cat $vtfile | xzminidec | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
fi
|
||||
|
||||
else
|
||||
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
fi
|
||||
else
|
||||
dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# param: file magic tmp
|
||||
ventoy_unpack_initrd() {
|
||||
vtfile=$1; vtmagic=$2; vttmp=$3
|
||||
echo "=====ventoy_unpack_initrd: #$*#" >> $VTLOG
|
||||
|
||||
for vtx in '1F8B zcat' '1F9E zcat' '425A bzcat' '5D00 lzcat' 'FD37 xzcat' '894C lzopcat' '0221 lz4cat' '28B5 zstdcat' '3037 cat'; do
|
||||
if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then
|
||||
echo "vtx=$vtx" >> $VTLOG
|
||||
${vtx:5} $vtfile > $vttmp
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# This export is for busybox cpio command
|
||||
export EXTRACT_UNSAFE_SYMLINKS=1
|
||||
|
||||
for vtfile in $(ls /initrd*); do
|
||||
#decompress first initrd
|
||||
vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $vtfile)
|
||||
|
||||
if ventoy_is_initrd_ramdisk; then
|
||||
ventoy_unpack_initrd $vtfile $vtmagic ${vtfile}_tmp
|
||||
mv ${vtfile}_tmp $vtfile
|
||||
break
|
||||
else
|
||||
ventoy_unpack_initramfs $vtfile 0 $vtmagic ${vtfile}_tmp
|
||||
fi
|
||||
|
||||
#only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported
|
||||
while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do
|
||||
mv ${vtfile}_tmp $vtfile
|
||||
vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile)
|
||||
vtmagic=$(echo $vtdump | sed 's/^\(00\)*//')
|
||||
let vtoffset="(${#vtdump}-${#vtmagic})/2"
|
||||
|
||||
if [ -z "$vtmagic" ]; then
|
||||
echo "terminate with all zero data file" >> $VTLOG
|
||||
break
|
||||
fi
|
||||
|
||||
ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp
|
||||
done
|
||||
|
||||
rm -f $vtfile ${vtfile}_tmp
|
||||
done
|
||||
|
||||
|
||||
#break here for debug
|
||||
if [ "$VTOY_BREAK_LEVEL" = "02" ] || [ "$VTOY_BREAK_LEVEL" = "12" ]; then
|
||||
sleep 5
|
||||
echo -e "\n\n\033[32m ################################################# \033[0m"
|
||||
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
|
||||
echo -e "\033[32m ################################################# \033[0m \n"
|
||||
if [ "$VTOY_BREAK_LEVEL" = "12" ]; then
|
||||
cat $VTOY_PATH/log
|
||||
fi
|
||||
exec $BUSYBOX_PATH/sh
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 3 : Extract injection archive #
|
||||
# #
|
||||
####################################################################
|
||||
ventoy_unpack_injection() {
|
||||
vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $VTOY_PATH/ventoy_injection)
|
||||
echo "ventoy_unpack_injection vtmagic=$vtmagic ..."
|
||||
|
||||
if [ "1F8B" = "$vtmagic" ] || [ "1F9E" = "$vtmagic" ]; then
|
||||
echo "tar.gz tar -xzvf"
|
||||
tar -xzvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "425A" = "$vtmagic" ]; then
|
||||
echo "tar.bz2 tar -xjvf"
|
||||
tar -xjvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "FD37" = "$vtmagic" ]; then
|
||||
echo "tar.xz tar -xJvf"
|
||||
tar -xJvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "5D00" = "$vtmagic" ]; then
|
||||
echo "tar.lzma tar -xavf"
|
||||
tar -xavf $VTOY_PATH/ventoy_injection -C /
|
||||
else
|
||||
echo "unzip -o"
|
||||
unzip -o $VTOY_PATH/ventoy_injection -d /
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -e $VTOY_PATH/ventoy_injection ]; then
|
||||
echo "### decompress injection ... ###" >>$VTLOG
|
||||
ventoy_unpack_injection > $VTOY_PATH/injection.log 2>&1
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 4 : Hand over to ventoy_chain.sh #
|
||||
# #
|
||||
####################################################################
|
||||
echo "Now hand over to ventoy.sh" >>$VTLOG
|
||||
. $VTOY_PATH/tool/vtoytool_install.sh
|
||||
|
||||
export PATH=$VTOY_ORG_PATH
|
||||
exec $BUSYBOX_PATH/sh $VTOY_PATH/ventoy_chain.sh
|
90
IMG/cpio/ventoy/init_loop
Normal file
90
IMG/cpio/ventoy/init_loop
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/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/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
|
||||
###################################################################
|
||||
# #
|
||||
# Step 1 : parse kernel debug parameter #
|
||||
# #
|
||||
####################################################################
|
||||
[ -d /proc ] || mkdir /proc; mount -t proc proc /proc
|
||||
vtcmdline=$(cat /proc/cmdline)
|
||||
vtkerver=$(cat /proc/version)
|
||||
umount /proc; rm -rf /proc
|
||||
|
||||
echo "kenel version=$vtkerver" >>$VTLOG
|
||||
echo "kenel cmdline=$vtcmdline" >>$VTLOG
|
||||
|
||||
#break here for debug
|
||||
if [ "$VTOY_BREAK_LEVEL" = "01" ] || [ "$VTOY_BREAK_LEVEL" = "11" ]; then
|
||||
sleep 5
|
||||
echo -e "\n\n\033[32m ################################################# \033[0m"
|
||||
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
|
||||
echo -e "\033[32m ################################################# \033[0m \n"
|
||||
|
||||
if [ "$VTOY_BREAK_LEVEL" = "11" ]; then
|
||||
cat $VTLOG
|
||||
fi
|
||||
exec $BUSYBOX_PATH/sh
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 2 : Extract injection archive #
|
||||
# #
|
||||
####################################################################
|
||||
ventoy_unpack_injection() {
|
||||
vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $VTOY_PATH/ventoy_injection)
|
||||
echo "ventoy_unpack_injection vtmagic=$vtmagic ..."
|
||||
|
||||
if [ "1F8B" = "$vtmagic" ] || [ "1F9E" = "$vtmagic" ]; then
|
||||
echo "tar.gz tar -xzvf"
|
||||
tar -xzvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "425A" = "$vtmagic" ]; then
|
||||
echo "tar.bz2 tar -xjvf"
|
||||
tar -xjvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "FD37" = "$vtmagic" ]; then
|
||||
echo "tar.xz tar -xJvf"
|
||||
tar -xJvf $VTOY_PATH/ventoy_injection -C /
|
||||
elif [ "5D00" = "$vtmagic" ]; then
|
||||
echo "tar.lzma tar -xavf"
|
||||
tar -xavf $VTOY_PATH/ventoy_injection -C /
|
||||
else
|
||||
echo "unzip -o"
|
||||
unzip -o $VTOY_PATH/ventoy_injection -d /
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -e $VTOY_PATH/ventoy_injection ]; then
|
||||
echo "### decompress injection ... ###" >>$VTLOG
|
||||
ventoy_unpack_injection > $VTOY_PATH/injection.log 2>&1
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 3 : Hand over to ventoy_loop.sh #
|
||||
# #
|
||||
####################################################################
|
||||
echo "Now hand over to ventoy.sh" >>$VTLOG
|
||||
. $VTOY_PATH/tool/vtoytool_install.sh
|
||||
|
||||
export PATH=$VTOY_ORG_PATH
|
||||
exec $BUSYBOX_PATH/sh $VTOY_PATH/ventoy_loop.sh
|
36
IMG/cpio/ventoy/loop/deepin/ventoy-disk.sh
Normal file
36
IMG/cpio/ventoy/loop/deepin/ventoy-disk.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/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/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
cd /ventoy
|
||||
xzcat tool.cpio.xz | cpio -idmu
|
||||
/ventoy/tool/vtoytool/00/vtoytool_64 --install
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
line=$(/ventoy/tool/vtoydump -f /ventoy/ventoy_os_param)
|
||||
if [ $? -eq 0 ]; then
|
||||
vtdiskname=${line%%#*}
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "ventoy disk is $vtdiskname" >> /ventoy/log
|
||||
/ventoy/tool/vtoydm -p -f /ventoy/ventoy_image_map -d $vtdiskname > /ventoy/ventoy_dm_table
|
||||
dmsetup create ventoy /ventoy/ventoy_dm_table --readonly
|
21
IMG/cpio/ventoy/loop/deepin/ventoy-init.sh
Normal file
21
IMG/cpio/ventoy/loop/deepin/ventoy-init.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/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 "/^mountroot$/i\\sh /ventoy/loop/deepin/ventoy-disk.sh" -i /init
|
||||
exec /init
|
36
IMG/cpio/ventoy/loop/endless/ventoy-hook.sh
Normal file
36
IMG/cpio/ventoy/loop/endless/ventoy-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/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
END_UDEV_DIR=$(ventoy_get_udev_conf_dir)
|
||||
|
||||
if ! [ -e "$END_UDEV_DIR/10-dm.rules" ]; then
|
||||
echo 'Copy dm rule file' >> $VTLOG
|
||||
$CAT $VTOY_PATH/hook/default/10-dm.rules > "$END_UDEV_DIR/10-dm.rules"
|
||||
fi
|
||||
|
||||
if ! [ -e "$END_UDEV_DIR/13-dm-disk.rules" ]; then
|
||||
echo 'Copy dm-disk rule file' >> $VTLOG
|
||||
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$END_UDEV_DIR/13-dm-disk.rules"
|
||||
fi
|
||||
|
||||
ventoy_set_loop_inotify_script endless/ventoy-inotifyd-hook.sh
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/loop/endless/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
|
||||
|
37
IMG/cpio/ventoy/loop/endless/ventoy-inotifyd-hook.sh
Normal file
37
IMG/cpio/ventoy/loop/endless/ventoy-inotifyd-hook.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/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; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$PATH:$BUSYBOX_PATH:$VTOY_PATH/tool
|
||||
|
||||
if is_inotify_ventoy_part $3; then
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (YES) ..."
|
||||
|
||||
ventoy_udev_disk_common_hook "$3" "noreplace"
|
||||
set_ventoy_hook_finish
|
||||
else
|
||||
vtlog "##### INOTIFYD: $2/$3 is created (NO) ..."
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
31
IMG/cpio/ventoy/loop/endless/ventoy-inotifyd-start.sh
Normal file
31
IMG/cpio/ventoy/loop/endless/ventoy-inotifyd-start.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/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtHook=$($CAT $VTOY_PATH/inotifyd-loop-script.txt)
|
||||
|
||||
vtdisk=$(get_ventoy_disk_name)
|
||||
if [ "$vtdisk" = "unknown" ]; then
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||
else
|
||||
vtlog "... $vtdisk already exist ..."
|
||||
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||
fi
|
@@ -136,6 +136,8 @@ ventoy_get_os_type() {
|
||||
echo 'suse'; return
|
||||
elif $GREP -q 'uruk' /etc/os-release; then
|
||||
echo 'debian'; return
|
||||
elif $GREP -q 'Solus' /etc/os-release; then
|
||||
echo 'rhel7'; return
|
||||
fi
|
||||
fi
|
||||
|
116
IMG/cpio/ventoy/ventoy_loop.sh
Normal file
116
IMG/cpio/ventoy/ventoy_loop.sh
Normal file
@@ -0,0 +1,116 @@
|
||||
#!/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/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 1 : Parse kernel parameter #
|
||||
# #
|
||||
####################################################################
|
||||
if ! [ -e /proc ]; then
|
||||
$BUSYBOX_PATH/mkdir /proc
|
||||
rmproc='Y'
|
||||
fi
|
||||
$BUSYBOX_PATH/mount -t proc proc /proc
|
||||
|
||||
# vtinit=xxx to replace rdinit=xxx
|
||||
vtcmdline=$($CAT /proc/cmdline)
|
||||
for i in $vtcmdline; do
|
||||
if echo $i | $GREP -q vtinit; then
|
||||
user_rdinit=${i#vtinit=}
|
||||
echo "user set user_rdinit=${user_rdinit}" >>$VTLOG
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 2 : Do OS specific hook #
|
||||
# #
|
||||
####################################################################
|
||||
ventoy_get_os_type() {
|
||||
echo "kernel version" >> $VTLOG
|
||||
$CAT /proc/version >> $VTLOG
|
||||
|
||||
# deepin-live
|
||||
if $GREP -q 'deepin' /proc/version; then
|
||||
echo 'deepin'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'endless' /proc/version; then
|
||||
echo 'endless'; return
|
||||
fi
|
||||
|
||||
echo "default"
|
||||
}
|
||||
|
||||
VTOS=$(ventoy_get_os_type)
|
||||
echo "OS=###${VTOS}###" >>$VTLOG
|
||||
if [ -e "$VTOY_PATH/loop/$VTOS/ventoy-hook.sh" ]; then
|
||||
$BUSYBOX_PATH/sh "$VTOY_PATH/loop/$VTOS/ventoy-hook.sh"
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 3 : Check for debug break #
|
||||
# #
|
||||
####################################################################
|
||||
if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then
|
||||
$SLEEP 5
|
||||
echo -e "\n\n\033[32m ################################################# \033[0m"
|
||||
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
|
||||
echo -e "\033[32m ################################################# \033[0m \n"
|
||||
if [ "$VTOY_BREAK_LEVEL" = "13" ]; then
|
||||
$CAT $VTOY_PATH/log
|
||||
fi
|
||||
exec $BUSYBOX_PATH/sh
|
||||
fi
|
||||
|
||||
|
||||
####################################################################
|
||||
# #
|
||||
# Step 3 : Hand over to real init #
|
||||
# #
|
||||
####################################################################
|
||||
$BUSYBOX_PATH/umount /proc
|
||||
if [ "$rmproc" = "Y" ]; then
|
||||
$BUSYBOX_PATH/rm -rf /proc
|
||||
fi
|
||||
|
||||
cd /
|
||||
|
||||
unset VTLOG FIND GREP EGREP CAT AWK SED SLEEP HEAD
|
||||
|
||||
for vtinit in $user_rdinit /sbin/init /init /linuxrc; do
|
||||
if [ -d /ventoy_rdroot ]; then
|
||||
if [ -e "/ventoy_rdroot$vtinit" ]; then
|
||||
# switch_root will check /init file, this is a cheat code
|
||||
echo 'switch_root' > /init
|
||||
exec $BUSYBOX_PATH/switch_root /ventoy_rdroot "$vtinit"
|
||||
fi
|
||||
else
|
||||
if [ -e "$vtinit" ];then
|
||||
exec "$vtinit"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Should never reach here
|
||||
echo -e "\n\n\033[31m ############ INIT NOT FOUND ############### \033[0m \n"
|
||||
exec $BUSYBOX_PATH/sh
|
Reference in New Issue
Block a user