Fix config struct exports
This commit is contained in:
parent
c64da46cce
commit
8a2ddeb261
2 changed files with 26 additions and 29 deletions
|
@ -14,20 +14,20 @@ func getBootloader(config *Config) {
|
||||||
_, err := command.Run("which", "grub-mkconfig")
|
_, err := command.Run("which", "grub-mkconfig")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Mark bootloader as grub2
|
// Mark bootloader as grub2
|
||||||
config.bootloader = "grub2"
|
config.Bootloader = "grub2"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for grubby (used by fedora)
|
// Check for grubby (used by fedora)
|
||||||
_, 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 = "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for kernelstub (used by pop os)
|
// Check for kernelstub (used by pop os)
|
||||||
_, err = command.Run("which", "kernelstub")
|
_, err = command.Run("which", "kernelstub")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
config.bootloader = "kernelstub"
|
config.Bootloader = "kernelstub"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,19 +42,19 @@ func set_Cmdline() {
|
||||||
config := GetConfig()
|
config := GetConfig()
|
||||||
|
|
||||||
// Write the file containing our kernel arguments to feed the bootloader
|
// Write the file containing our kernel arguments to feed the bootloader
|
||||||
fileio.AppendContent("iommu=pt", config.path.CMDLINE)
|
fileio.AppendContent("iommu=pt", config.Path.CMDLINE)
|
||||||
|
|
||||||
// Write the argument based on which cpu the user got
|
// Write the argument based on which cpu the user got
|
||||||
switch cpuinfo.VendorString {
|
switch cpuinfo.VendorString {
|
||||||
case "AuthenticAMD":
|
case "AuthenticAMD":
|
||||||
fileio.AppendContent(" amd_iommu=on", config.path.CMDLINE)
|
fileio.AppendContent(" amd_iommu=on", config.Path.CMDLINE)
|
||||||
case "GenuineIntel":
|
case "GenuineIntel":
|
||||||
fileio.AppendContent(" intel_iommu=on", config.path.CMDLINE)
|
fileio.AppendContent(" intel_iommu=on", config.Path.CMDLINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the config folder for dracut exists in our configs
|
// If the config folder for dracut exists in our configs
|
||||||
if fileio.FileExist(config.path.DRACUT) {
|
if fileio.FileExist(config.Path.DRACUT) {
|
||||||
// Add an extra kernel argument needed for dracut users
|
// Add an extra kernel argument needed for dracut users
|
||||||
fileio.AppendContent(" rd.driver.pre=vfio_pci", config.path.CMDLINE)
|
fileio.AppendContent(" rd.driver.pre=vfio_pci", config.Path.CMDLINE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ type Path struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
bootloader string
|
Bootloader string
|
||||||
cpuvendor string
|
Cpuvendor string
|
||||||
path *Path
|
Path *Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConfigPaths() *Path {
|
func GetConfigPaths() *Path {
|
||||||
|
@ -43,18 +43,15 @@ func GetConfigPaths() *Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConfig() *Config {
|
func GetConfig() *Config {
|
||||||
config := &Config{}
|
config := &Config{
|
||||||
config.path = GetConfigPaths()
|
Bootloader: "unknown",
|
||||||
|
Cpuvendor: cpuid.CPU.VendorString,
|
||||||
// Set default value for bootloader
|
Path: GetConfigPaths(),
|
||||||
config.bootloader = "unknown"
|
}
|
||||||
|
|
||||||
// Detect the bootloader we are using
|
// Detect the bootloader we are using
|
||||||
getBootloader(config)
|
getBootloader(config)
|
||||||
|
|
||||||
// Detect the cpu vendor
|
|
||||||
config.cpuvendor = cpuid.CPU.VendorString
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,10 +60,10 @@ func InitConfigs() {
|
||||||
|
|
||||||
// Add all directories we need into a stringlist
|
// Add all directories we need into a stringlist
|
||||||
dirs := []string{
|
dirs := []string{
|
||||||
config.path.MODPROBE,
|
config.Path.MODPROBE,
|
||||||
config.path.INITRAMFS,
|
config.Path.INITRAMFS,
|
||||||
config.path.DEFAULT,
|
config.Path.DEFAULT,
|
||||||
config.path.DRACUT,
|
config.Path.DRACUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove old config
|
// Remove old config
|
||||||
|
@ -93,10 +90,10 @@ func InitConfigs() {
|
||||||
|
|
||||||
// Add all files we need to a stringlist
|
// Add all files we need to a stringlist
|
||||||
files := []string{
|
files := []string{
|
||||||
config.path.ETCMODULES,
|
config.Path.ETCMODULES,
|
||||||
config.path.MKINITCPIO,
|
config.Path.MKINITCPIO,
|
||||||
fmt.Sprintf("%s/modules", config.path.INITRAMFS),
|
fmt.Sprintf("%s/modules", config.Path.INITRAMFS),
|
||||||
fmt.Sprintf("%s/grub", config.path.DEFAULT),
|
fmt.Sprintf("%s/grub", config.Path.DEFAULT),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, conffile := range files {
|
for _, conffile := range files {
|
||||||
|
@ -115,14 +112,14 @@ func InitConfigs() {
|
||||||
// If we now have a config that exists
|
// If we now have a config that exists
|
||||||
if fileio.FileExist(conffile) {
|
if fileio.FileExist(conffile) {
|
||||||
switch conffile {
|
switch conffile {
|
||||||
case config.path.ETCMODULES:
|
case config.Path.ETCMODULES:
|
||||||
// Read the header
|
// Read the header
|
||||||
header := initramfs_readHeader(4, sysfile)
|
header := initramfs_readHeader(4, sysfile)
|
||||||
fileio.AppendContent(header, conffile)
|
fileio.AppendContent(header, conffile)
|
||||||
|
|
||||||
// Add the modules to the config file
|
// Add the modules to the config file
|
||||||
initramfs_addModules(conffile)
|
initramfs_addModules(conffile)
|
||||||
case fmt.Sprintf("%s/modules", config.path.INITRAMFS):
|
case fmt.Sprintf("%s/modules", config.Path.INITRAMFS):
|
||||||
// Read the header
|
// Read the header
|
||||||
header := initramfs_readHeader(11, sysfile)
|
header := initramfs_readHeader(11, sysfile)
|
||||||
fileio.AppendContent(header, conffile)
|
fileio.AppendContent(header, conffile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue