X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/ad9a031092f1d953d10bcf6ec77cb2fa1fc2c103..fc5cd0a00a6745d7a8ce31bfadd76e8d064e18a1:/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh diff --git a/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh b/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh index aa1f7fc..d3d7ab8 100644 --- a/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh +++ b/IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh @@ -22,10 +22,73 @@ #ventoy_systemd_udevd_work_around #ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace" -$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0#" -i /lib/dracut-lib.sh +if [ -f $VTOY_PATH/autoinstall ]; then + VTKS="inst.ks=file:$VTOY_PATH/autoinstall" +else + for vtParam in $($CAT /proc/cmdline); do + if echo $vtParam | $GREP -q 'inst.ks=hd:LABEL='; then + vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}') + VTKS="inst.ks=hd:/dev/dm-0:$vtRawKs" + break + fi + + if echo $vtParam | $GREP -q '^ks=.*:/'; then + vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}') + VTKS="ks=hd:/dev/dm-0:$vtRawKs" + break + fi + done +fi + +if [ -f $VTOY_PATH/ventoy_persistent_map ]; then + VTOVERLAY="rd.live.overlay=/dev/dm-1:/vtoyoverlayfs/overlayfs" + + if [ -e /sbin/dmsquash-live-root ]; then + echo "patch /sbin/dmsquash-live-root for persistent ..." >> $VTLOG + $SED "/mount.*devspec.*\/run\/initramfs\/overlayfs/a . /ventoy/hook/rhel7/ventoy-overlay.sh" -i /sbin/dmsquash-live-root + fi + + #close selinux + $BUSYBOX_PATH/mkdir -p $VTOY_PATH/selinuxfs + if $BUSYBOX_PATH/mount -t selinuxfs selinuxfs $VTOY_PATH/selinuxfs; then + echo 1 > $VTOY_PATH/selinuxfs/disable + $BUSYBOX_PATH/umount $VTOY_PATH/selinuxfs + fi + $BUSYBOX_PATH/rm -rf $VTOY_PATH/selinuxfs +fi + + +echo "VTKS=$VTKS VTOVERLAY=$VTOVERLAY" >> $VTLOG + +if ls $VTOY_PATH | $GREP -q 'ventoy_dud[0-9]'; then + for vtDud in $(ls $VTOY_PATH/ventoy_dud*); do + vtInstDD="$vtInstDD inst.dd=file:$vtDud" + done +fi +echo "vtInstDD=$vtInstDD" >> $VTLOG + +if $GREP -q 'root=live' /proc/cmdline; then + $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh +else + $SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS $VTOVERLAY $vtInstDD#" -i /lib/dracut-lib.sh +fi + ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh -$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.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 +fi # suppress write protected mount warning if [ -e /usr/sbin/anaconda-diskroot ]; then