diff --git a/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh b/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh index 3ab212bd..852e4136 100644 --- a/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh +++ b/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh @@ -24,6 +24,7 @@ if [ -f $VTOY_PATH/autoinstall ]; then VTKS="inst.ks=file:$VTOY_PATH/autoinstall" + cp -a $VTOY_PATH/hook/rhel7/ventoy-autoexp.sh /lib/dracut/hooks/pre-mount/99-ventoy-autoexp.sh else for vtParam in $($CAT /proc/cmdline); do if echo $vtParam | $GREP -q 'ks=file:/'; then @@ -90,23 +91,7 @@ if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then fi echo "vtInstDD=$vtInstDD" >> $VTLOG -if $GREP -q 'root=live' /proc/cmdline; then - $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/ventoy $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh -else - $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/ventoy $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh -fi -ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh - -#Fedora -if $BUSYBOX_PATH/which dmsquash-live-root > /dev/null; then - vtPriority=99 -else - vtPriority=01 -fi - -$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh -$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh vtNeedRepo= if [ -f /etc/system-release ]; then @@ -131,13 +116,53 @@ if $GREP -i -q Fedora /etc/os-release; then fi fi - echo "vtNeedRepo=$vtNeedRepo" >> $VTLOG if [ "$vtNeedRepo" = "yes" ]; then $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-repo.sh /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh fi + +#iso-scan (currently only for Fedora) +if $GREP -q Fedora /etc/os-release; then + if ventoy_iso_scan_check; then + echo "iso_scan process ..." >> $VTLOG + + vtIsoPath=$(/ventoy/tool/vtoydump -p /ventoy/ventoy_os_param) + VTISO_SCAN="iso-scan/filename=$vtIsoPath" + echo -n $vtIsoPath > /ventoy/vtoy_iso_scan + + $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE $VTISO_SCAN $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh + if [ "$VTOY_LINUX_REMOUNT" = "01" -a "$vtNeedRepo" != "yes" ]; then + ventoy_rw_iso_scan + fi + + exit 0 + fi +fi + + +echo "common process ..." >> $VTLOG +if $GREP -q 'root=live' /proc/cmdline; then + $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/ventoy $VTKS $VTOVERLAY $VTISO_SCAN $vtInstDD#" -i /lib/dracut-lib.sh +else + $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/ventoy $VTKS $VTOVERLAY $VTISO_SCAN $vtInstDD#" -i /lib/dracut-lib.sh +fi + + +ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh + +#Fedora +if $BUSYBOX_PATH/which dmsquash-live-root > /dev/null; then + vtPriority=99 +else + vtPriority=01 +fi + +$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh +$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh + + if [ -e /sbin/dmsquash-live-root ]; then echo "patch /sbin/dmsquash-live-root ..." >> $VTLOG $SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/rhel7/ventoy-make-link.sh" -i /sbin/dmsquash-live-root @@ -154,10 +179,6 @@ if $GREP -i -q 'fedora.*coreos' /etc/os-release; then cp -a $VTOY_PATH/hook/rhel7/ventoy-make-link.sh /lib/dracut/hooks/pre-mount/99-ventoy-premount-mklink.sh fi -if [ -f $VTOY_PATH/autoinstall ]; then - cp -a $VTOY_PATH/hook/rhel7/ventoy-autoexp.sh /lib/dracut/hooks/pre-mount/99-ventoy-autoexp.sh -fi - #special distro magic $BUSYBOX_PATH/mkdir -p $VTOY_PATH/distmagic diff --git a/IMG/cpio/ventoy/hook/rhel7/ventoy-repo.sh b/IMG/cpio/ventoy/hook/rhel7/ventoy-repo.sh index af85bebd..002aa5e7 100644 --- a/IMG/cpio/ventoy/hook/rhel7/ventoy-repo.sh +++ b/IMG/cpio/ventoy/hook/rhel7/ventoy-repo.sh @@ -23,7 +23,18 @@ vtlog "##### $0 $* ..." VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH -repodev=$(ls $VTOY_PATH/dev_backup*) -echo "inst.repo=hd:/dev/${repodev#*dev_backup_}" >> /sysroot/etc/cmdline +if [ -f /ventoy/vtoy_iso_scan ]; then + repopath=$(cat /ventoy/vtoy_iso_scan) + repodev=$(vtoydump -f /ventoy/ventoy_os_param | awk -F'#' '{print $1}') + if echo $repodev | egrep -q "nvme|mmc|nbd"; then + vtpart1=${repodev}p1 + else + vtpart1=${repodev}1 + fi + echo "inst.repo=hd:${vtpart1}:${repopath}" >> /sysroot/etc/cmdline +else + repodev=$(ls $VTOY_PATH/dev_backup*) + echo "inst.repo=hd:/dev/${repodev#*dev_backup_}" >> /sysroot/etc/cmdline +fi PATH=$VTPATH_OLD diff --git a/IMG/cpio/ventoy/hook/ventoy-os-lib.sh b/IMG/cpio/ventoy/hook/ventoy-os-lib.sh index dbd015f8..693a96b7 100644 --- a/IMG/cpio/ventoy/hook/ventoy-os-lib.sh +++ b/IMG/cpio/ventoy/hook/ventoy-os-lib.sh @@ -121,3 +121,48 @@ ventoy_check_mount() { $BUSYBOX_PATH/mount $1 $2 fi } + +ventoy_has_exfat_ko() { + vtExfat='' + vtKerVer=$($BUSYBOX_PATH/uname -r) + if [ -d /lib/modules/$vtKerVer/kernel/fs/exfat ]; then + vtExfat=$(ls /lib/modules/$vtKerVer/kernel/fs/exfat/) + fi + [ -n "$vtExfat" ] +} + +ventoy_is_exfat_part() { + $VTOY_PATH/tool/vtoydump -s /ventoy/ventoy_os_param | $GREP -q exfat +} + +ventoy_iso_scan_path() { + if [ -f /sbin/iso-scan ]; then + echo -n '/sbin/iso-scan' + elif [ -f /bin/iso-scan ]; then + echo -n '/bin/iso-scan' + else + echo -n '' + fi +} + +ventoy_has_iso_scan() { + vtScanPath=$(ventoy_iso_scan_path) + [ -n "$vtScanPath" ] +} + +ventoy_rw_iso_scan() { + vtScanPath=$(ventoy_iso_scan_path) + if [ -n "$vtScanPath" ]; then + if $GREP -q 'mount.* ro .*isoscan' $vtScanPath; then + $SED -i 's/\(mount.*-o.*\) ro /\1 rw /' $vtScanPath + fi + fi +} + +ventoy_iso_scan_check() { + if ventoy_is_exfat_part; then + if ventoy_has_exfat_ko; then + ventoy_has_iso_scan + fi + fi +} \ No newline at end of file