* Combine provision response handling, add hwaddr and interface to dhcp * Simplify stage cases, add backward compatible uri parse * Move control of image compression to client * Fix kernel search path for ubuntu, buffer template generation * Implement cpio and gz as functions, add log named functions * Generalize fs image creation routine * Combine daemonLogf to generalized wwlog * Fix template newline insertion, update dhcp and hosts tmpl * Update IPXE template to handle non-compressed files * Update DHCP template to set network interfaces and server IP assignment * Update DHCP/hosts templates to choose a host-name self-consistently
70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
package container
|
|
|
|
import (
|
|
"path"
|
|
"path/filepath"
|
|
"sort"
|
|
|
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
|
)
|
|
|
|
var (
|
|
kernelNames = []string{
|
|
`vmlinux`,
|
|
`vmlinuz`,
|
|
`vmlinux-*`,
|
|
`vmlinuz-*`,
|
|
`vmlinuz.gz` }
|
|
|
|
kernelDirs = []string{
|
|
`/lib/modules/*/`,
|
|
`/boot/` }
|
|
)
|
|
|
|
func KernelFind(container string) string {
|
|
wwlog.Printf(wwlog.DEBUG, "Finding kernel\n")
|
|
container_path := RootFsDir(container)
|
|
if container_path == "" {
|
|
return ""
|
|
}
|
|
|
|
for _, kdir := range kernelDirs {
|
|
wwlog.Printf(wwlog.DEBUG, "Checking kernel directory: %s\n", kdir)
|
|
for _, kname := range kernelNames {
|
|
wwlog.Printf(wwlog.DEBUG, "Checking for kernel name: %s\n", kname)
|
|
kernelPaths, err := filepath.Glob(path.Join(container_path, kdir, kname))
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
if len(kernelPaths) == 0 {
|
|
continue
|
|
}
|
|
|
|
sort.Slice(kernelPaths, func(i, j int) bool {
|
|
return kernelPaths[i] > kernelPaths[j]
|
|
})
|
|
|
|
for _, kernelPath := range kernelPaths {
|
|
wwlog.Printf(wwlog.DEBUG, "Checking for kernel path: %s\n", kernelPath)
|
|
if util.IsFile(kernelPath) {
|
|
return kernelPath
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
func KernelVersion(container string) string {
|
|
wwlog.Printf(wwlog.DEBUG, "Finding kernel version inside container: %s\n", container)
|
|
kernel := KernelFind(container)
|
|
if kernel == "" {
|
|
return ""
|
|
}
|
|
|
|
return path.Base(path.Dir(kernel))
|
|
}
|