add support for grub configs that do not use GRUB_CMDLINE_LINUX_DEFAULT variable
This commit is contained in:
parent
4abea3d6d5
commit
34dd4212d2
1 changed files with 16 additions and 4 deletions
|
@ -36,11 +36,23 @@ function set_GRUB () {
|
||||||
CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args")
|
CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args")
|
||||||
|
|
||||||
# HIGHLY EXPERIMENTAL!
|
# HIGHLY EXPERIMENTAL!
|
||||||
GRUB_CMDLINE=$(cat "/etc/default/grub" | grep -P "^GRUB_CMDLINE_LINUX_DEFAULT" | perl -pe "s/GRUB_CMDLINE_LINUX_DEFAULT=\"(.+)\"/\1/" | perl -pe "s/iommu=(pt|on)|amd_iommu=on|vfio_pci.ids=.+|vfio_pci.disable_vga=\d{1}//g" | perl -pe "s/(^\s+|\s+$)//g")
|
local GRUB_CMDLINE
|
||||||
GRUB_CMDLINE_LINUX_DEFAULT=$(cat "/etc/default/grub" | grep -P "^GRUB_CMDLINE_LINUX_DEFAULT")
|
local GRUB_CMDLINE_LINUX
|
||||||
|
|
||||||
# Update the GRUB_CMDLINE_LINUX_DEFAULT line
|
# Check if there is a GRUB_CMDLINE_LINUX_DEFAULT line in grub config
|
||||||
perl -pi -e "s/${GRUB_CMDLINE_LINUX_DEFAULT}/GRUB_CMDLINE_LINUX_DEFAULT=\"${GRUB_CMDLINE} ${CMDLINE}\"/" "${SCRIPTDIR}/config/etc/default/grub"
|
if grep -q "GRUB_CMDLINE_LINUX_DEFAULT=" ;
|
||||||
|
then
|
||||||
|
# Update the GRUB_CMDLINE_LINUX_DEFAULT line
|
||||||
|
GRUB_CMDLINE=$(cat "/etc/default/grub" | grep -P "^GRUB_CMDLINE_LINUX_DEFAULT" | perl -pe "s/GRUB_CMDLINE_LINUX_DEFAULT=\"(.+)\"/\1/" | perl -pe "s/iommu=(pt|on)|amd_iommu=on|vfio_pci.ids=.+|vfio_pci.disable_vga=\d{1}//g" | perl -pe "s/(^\s+|\s+$)//g")
|
||||||
|
GRUB_CMDLINE_LINUX=$(cat "/etc/default/grub" | grep -P "^GRUB_CMDLINE_LINUX_DEFAULT")
|
||||||
|
perl -pi -e "s/${GRUB_CMDLINE_LINUX}/GRUB_CMDLINE_LINUX_DEFAULT=\"${GRUB_CMDLINE} ${CMDLINE}\"/" "${SCRIPTDIR}/config/etc/default/grub"
|
||||||
|
else
|
||||||
|
# Update the GRUB_CMDLINE_LINUX line
|
||||||
|
GRUB_CMDLINE=$(cat "/etc/default/grub" | grep -P "^GRUB_CMDLINE_LINUX" | perl -pe "s/GRUB_CMDLINE_LINUX=\"(.+)\"/\1/" | perl -pe "s/iommu=(pt|on)|amd_iommu=on|vfio_pci.ids=.+|vfio_pci.disable_vga=\d{1}//g" | perl -pe "s/(^\s+|\s+$)//g")
|
||||||
|
GRUB_CMDLINE_LINUX=$(cat "/etc/default/grub" | grep -P "^GRUB_CMDLINE_LINUX")
|
||||||
|
perl -pi -e "s/${GRUB_CMDLINE_LINUX}/GRUB_CMDLINE_LINUX=\"${GRUB_CMDLINE} ${CMDLINE}\"/" "${SCRIPTDIR}/config/etc/default/grub"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "The script will now replace your default grub file with a new one.
|
echo "The script will now replace your default grub file with a new one.
|
||||||
Then attempt to update grub and generate a new grub.cfg.
|
Then attempt to update grub and generate a new grub.cfg.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue