Add function for setting cmdline and writing the config/cmdline file
This commit is contained in:
parent
3ee1062f71
commit
c3a1639dee
2 changed files with 24 additions and 6 deletions
|
@ -6,6 +6,8 @@ import (
|
||||||
"github.com/klauspost/cpuid/v2"
|
"github.com/klauspost/cpuid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// This function just adds what bootloader the system has to our config.bootloader value
|
||||||
|
// Preference is given to kernelstub because it is WAY easier to safely edit compared to grub2
|
||||||
func getBootloader(config *Config) {
|
func getBootloader(config *Config) {
|
||||||
// Check what bootloader handler we are using
|
// Check what bootloader handler we are using
|
||||||
// Check for grub-mkconfig
|
// Check for grub-mkconfig
|
||||||
|
@ -29,6 +31,9 @@ func getBootloader(config *Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function adds the default kernel arguments we want to the config/cmdline file
|
||||||
|
// This gives us a file we can read all the kernel arguments this system needs
|
||||||
|
// in case of an unknown bootloader
|
||||||
func set_Cmdline() {
|
func set_Cmdline() {
|
||||||
// Get the system info
|
// Get the system info
|
||||||
cpuinfo := cpuid.CPU
|
cpuinfo := cpuid.CPU
|
||||||
|
@ -36,7 +41,20 @@ func set_Cmdline() {
|
||||||
// Get the configs
|
// Get the configs
|
||||||
config := GetConfig()
|
config := GetConfig()
|
||||||
|
|
||||||
// Write test file
|
// Write the file containing our kernel arguments to feed the bootloader
|
||||||
fileio.AppendContent(cpuinfo.VendorString, config.path.CMDLINE)
|
fileio.AppendContent("iommu=pt", config.path.CMDLINE)
|
||||||
fileio.AppendContent(cpuinfo.VendorString, config.path.CMDLINE)
|
|
||||||
|
// Write the argument based on which cpu the user got
|
||||||
|
switch cpuinfo.VendorString {
|
||||||
|
case "AuthenticAMD":
|
||||||
|
fileio.AppendContent(" amd_iommu=on", config.path.CMDLINE)
|
||||||
|
case "GenuineIntel":
|
||||||
|
fileio.AppendContent(" intel_iommu=on", config.path.CMDLINE)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the config folder for dracut exists in our configs
|
||||||
|
if fileio.FileExist(config.path.DRACUT) {
|
||||||
|
// Add an extra kernel argument needed for dracut users
|
||||||
|
fileio.AppendContent(" rd.driver.pre=vfio_pci", config.path.CMDLINE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,6 @@ func InitConfigs() {
|
||||||
// Make the config folder
|
// Make the config folder
|
||||||
os.Mkdir("config", os.ModePerm)
|
os.Mkdir("config", os.ModePerm)
|
||||||
|
|
||||||
// Generate the kernel arguments
|
|
||||||
set_Cmdline()
|
|
||||||
|
|
||||||
// Make a regex to get the system path instead of the config path
|
// Make a regex to get the system path instead of the config path
|
||||||
syspath_re := regexp.MustCompile(`^config`)
|
syspath_re := regexp.MustCompile(`^config`)
|
||||||
|
|
||||||
|
@ -136,4 +133,7 @@ func InitConfigs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate the kernel arguments
|
||||||
|
set_Cmdline()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue