syslinux.go 914 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package install
  2. import (
  3. "html/template"
  4. "os"
  5. "path/filepath"
  6. "github.com/rancher/os/log"
  7. )
  8. func syslinuxConfig(menu BootVars) error {
  9. log.Debugf("syslinuxConfig")
  10. filetmpl, err := template.New("syslinuxconfig").Parse(`{{define "syslinuxmenu"}}
  11. LABEL {{.Name}}
  12. LINUX ../vmlinuz-{{.Version}}-rancheros
  13. APPEND {{.KernelArgs}} {{.Append}}
  14. INITRD ../initrd-{{.Version}}-rancheros
  15. {{end}}
  16. TIMEOUT 20 #2 seconds
  17. DEFAULT RancherOS-current
  18. {{- range .Entries}}
  19. {{template "syslinuxmenu" .}}
  20. {{- end}}
  21. `)
  22. if err != nil {
  23. log.Errorf("syslinuxconfig %s", err)
  24. return err
  25. }
  26. cfgFile := filepath.Join(menu.BaseName, menu.BootDir+"syslinux/syslinux.cfg")
  27. log.Debugf("syslinuxConfig written to %s", cfgFile)
  28. f, err := os.Create(cfgFile)
  29. if err != nil {
  30. log.Errorf("Create(%s) %s", cfgFile, err)
  31. return err
  32. }
  33. err = filetmpl.Execute(f, menu)
  34. if err != nil {
  35. return err
  36. }
  37. return nil
  38. }