1
0
mirror of https://github.com/rancher/os.git synced 2025-09-20 18:13:35 +00:00
Files
os/pkg/init/modules/modules.go
Olli Janatuinen 872f1cd6da Initiate Burmilla OS project
- Use burmilla GitHub repos
- Release under burmilla Docker Hub
- GitHub action for create releases
- Updated boot image and login banner
- Use Debian as default console
- Updated system-cron to v0.5.0
- Updated services to latest versions
- Bump up kernel to 4.14.206
- Include burmilla/os-debianconsole:v1.9.0 to initrd
2021-02-18 20:07:36 +02:00

50 lines
1.0 KiB
Go

package modules
import (
"bufio"
"os"
"os/exec"
"strings"
"github.com/burmilla/os/config"
"github.com/burmilla/os/pkg/log"
"github.com/burmilla/os/pkg/util"
)
func LoadModules(cfg *config.CloudConfig) (*config.CloudConfig, error) {
mounted := map[string]bool{}
f, err := os.Open("/proc/modules")
if err != nil {
return cfg, err
}
defer f.Close()
reader := bufio.NewScanner(f)
for reader.Scan() {
mounted[strings.SplitN(reader.Text(), " ", 2)[0]] = true
}
if util.GetHypervisor() == "hyperv" {
cfg.Rancher.Modules = append(cfg.Rancher.Modules, "hv_utils", "hv_storvsc", "hv_vmbus")
}
for _, module := range cfg.Rancher.Modules {
if mounted[module] {
continue
}
log.Debugf("Loading module %s", module)
// split module and module parameters
cmdParam := strings.SplitN(module, " ", -1)
cmd := exec.Command("modprobe", cmdParam...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Errorf("Could not load module %s, err %v", module, err)
}
}
return cfg, reader.Err()
}