Implement grubby support
This commit is contained in:
parent
7081bfa8d7
commit
ff5d20f4f9
2 changed files with 28 additions and 4 deletions
|
@ -15,7 +15,7 @@ import (
|
||||||
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
|
||||||
_, err := command.Run("which", "grub-mkconfig")
|
_, err := command.Run("which", "grub2-mkconfig")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Mark bootloader as grub2
|
// Mark bootloader as grub2
|
||||||
config.Bootloader = "grub2"
|
config.Bootloader = "grub2"
|
||||||
|
@ -25,7 +25,7 @@ func getBootloader(config *Config) {
|
||||||
_, err = command.Run("which", "grubby")
|
_, err = command.Run("which", "grubby")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Mark it as unknown as i do not support it yet
|
// Mark it as unknown as i do not support it yet
|
||||||
config.Bootloader = "unknown"
|
config.Bootloader = "grubby"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for kernelstub (used by pop os)
|
// Check for kernelstub (used by pop os)
|
||||||
|
@ -60,9 +60,10 @@ func Set_Cmdline(gpu_IDs []string) {
|
||||||
fileio.AppendContent(fmt.Sprintf(" vfio_pci.ids=%s", strings.Join(gpu_IDs, ",")), config.Path.CMDLINE)
|
fileio.AppendContent(fmt.Sprintf(" vfio_pci.ids=%s", strings.Join(gpu_IDs, ",")), config.Path.CMDLINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: write functions to configure kernelstub and grub
|
// TODO: write functions to configure grub
|
||||||
// TODO2: look into grubby
|
|
||||||
// TODO3: if unknown bootloader, tell user what to add a kernel arguments
|
// TODO3: if unknown bootloader, tell user what to add a kernel arguments
|
||||||
|
|
||||||
|
// Configures systemd-boot using kernelstub
|
||||||
func Set_KernelStub() {
|
func Set_KernelStub() {
|
||||||
// Get the config
|
// Get the config
|
||||||
config := GetConfig()
|
config := GetConfig()
|
||||||
|
@ -76,3 +77,18 @@ func Set_KernelStub() {
|
||||||
// Run the command
|
// Run the command
|
||||||
command.Run("sudo", "kernelstub", "-a", kernel_args)
|
command.Run("sudo", "kernelstub", "-a", kernel_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configures grub2 or systemd-boot using grubby
|
||||||
|
func Set_Grubby() {
|
||||||
|
// Get the config
|
||||||
|
config := GetConfig()
|
||||||
|
|
||||||
|
// Get the kernel args
|
||||||
|
kernel_args := fileio.ReadFile(config.Path.CMDLINE)
|
||||||
|
|
||||||
|
// Write to logger
|
||||||
|
logger.Printf("Running command:\nsudo grubby --update-kernel=ALL --args=\"%s\"", kernel_args)
|
||||||
|
|
||||||
|
// Run the command
|
||||||
|
command.Run("sudo", "grubby", "--update-kernel=ALL", fmt.Sprintf("--args=%s", kernel_args))
|
||||||
|
}
|
||||||
|
|
|
@ -163,6 +163,14 @@ func (m *model) install(auth string) {
|
||||||
|
|
||||||
// Configure kernelstub
|
// Configure kernelstub
|
||||||
configs.Set_KernelStub()
|
configs.Set_KernelStub()
|
||||||
|
|
||||||
|
} else if config.Bootloader == "grubby" {
|
||||||
|
// Write to logger
|
||||||
|
logger.Printf("Configuring bootloader using grubby")
|
||||||
|
|
||||||
|
// Configure kernelstub
|
||||||
|
configs.Set_Grubby()
|
||||||
|
|
||||||
} else if config.Bootloader == "unknown" {
|
} else if config.Bootloader == "unknown" {
|
||||||
kernel_args := fileio.ReadFile(config.Path.CMDLINE)
|
kernel_args := fileio.ReadFile(config.Path.CMDLINE)
|
||||||
fmt.Printf("Unsupported bootloader, please add the below line to your bootloaders kernel arguments\n%s", kernel_args)
|
fmt.Printf("Unsupported bootloader, please add the below line to your bootloaders kernel arguments\n%s", kernel_args)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue