More fixes and usibility updates
This commit is contained in:
@@ -19,7 +19,7 @@ func ipxe(w http.ResponseWriter, req *http.Request) {
|
|||||||
hwaddr := strings.ReplaceAll(url[2], "-", ":")
|
hwaddr := strings.ReplaceAll(url[2], "-", ":")
|
||||||
node, err := assets.FindByHwaddr(hwaddr)
|
node, err := assets.FindByHwaddr(hwaddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Could not find HW Addr: %s\n", hwaddr)
|
log.Printf("Could not find HW Addr: %s: %s\n", hwaddr, err)
|
||||||
w.WriteHeader(404)
|
w.WriteHeader(404)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ func overlayRuntime(node assets.NodeInfo, replace map[string]string, wg *sync.Wa
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
destModTime = destMod.ModTime()
|
destModTime = destMod.ModTime()
|
||||||
}
|
}
|
||||||
configMod, err := os.Stat("/etc/warewulf/nodes.yaml")
|
configMod, err := os.Stat("/etc/warewulf/nodes.conf")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: could not find node file: /etc/warewulf/nodes.yaml")
|
fmt.Printf("ERROR: could not find node file: /etc/warewulf/nodes.conf")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
configModTime := configMod.ModTime()
|
configModTime := configMod.ModTime()
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ func overlaySystem(node assets.NodeInfo, replace map[string]string, wg *sync.Wai
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
destModTime = destMod.ModTime()
|
destModTime = destMod.ModTime()
|
||||||
}
|
}
|
||||||
configMod, err := os.Stat("/etc/warewulf/nodes.yaml")
|
configMod, err := os.Stat("/etc/warewulf/nodes.conf")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: could not find node file: /etc/warewulf/nodes.yaml")
|
fmt.Printf("ERROR: could not find node file: /etc/warewulf/nodes.conf\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
configModTime := configMod.ModTime()
|
configModTime := configMod.ModTime()
|
||||||
|
|||||||
@@ -52,10 +52,8 @@ func BuildOverlayDir(sourceDir string, destDir string, replace map[string]string
|
|||||||
replaceString := fmt.Sprintf("@%s@", strings.ToUpper(k))
|
replaceString := fmt.Sprintf("@%s@", strings.ToUpper(k))
|
||||||
newLine = strings.ReplaceAll(newLine, replaceString, v)
|
newLine = strings.ReplaceAll(newLine, replaceString, v)
|
||||||
}
|
}
|
||||||
//TODO: Support directives like '#INCLUDE <filename>' and
|
|
||||||
// conditionals like '#IFDEF ....`
|
|
||||||
|
|
||||||
if strings.HasPrefix(newLine, "#WWENDIF") {
|
if strings.HasPrefix(newLine, "#WWEND") {
|
||||||
skip = false
|
skip = false
|
||||||
} else if skip == true {
|
} else if skip == true {
|
||||||
|
|
||||||
@@ -64,6 +62,11 @@ func BuildOverlayDir(sourceDir string, destDir string, replace map[string]string
|
|||||||
if len(line) > 0 && line[1] != "false" {
|
if len(line) > 0 && line[1] != "false" {
|
||||||
skip = true
|
skip = true
|
||||||
}
|
}
|
||||||
|
} else if strings.HasPrefix(newLine, "#WWIFNDEF ") {
|
||||||
|
line := strings.Split(newLine, " ")
|
||||||
|
if len(line) > 0 && line[1] == "false" {
|
||||||
|
skip = true
|
||||||
|
}
|
||||||
} else if strings.HasPrefix(newLine, "#WWIF ") {
|
} else if strings.HasPrefix(newLine, "#WWIF ") {
|
||||||
line := strings.Split(newLine, " ")
|
line := strings.Split(newLine, " ")
|
||||||
if len(line) == 2 && line[1] != "false" {
|
if len(line) == 2 && line[1] != "false" {
|
||||||
@@ -76,13 +79,25 @@ func BuildOverlayDir(sourceDir string, destDir string, replace map[string]string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if strings.HasPrefix(newLine, "#WWELSE") {
|
||||||
|
if skip == true {
|
||||||
|
skip = false
|
||||||
|
} else {
|
||||||
|
skip = true
|
||||||
|
}
|
||||||
} else if strings.HasPrefix(newLine, "#WWINCLUDE ") {
|
} else if strings.HasPrefix(newLine, "#WWINCLUDE ") {
|
||||||
line := strings.Split(newLine, " ")
|
line := strings.Split(newLine, " ")
|
||||||
|
//fmt.Printf("Including file (%s): %s\n", destDir + "/" + destFile, line[1])
|
||||||
includeFD, err := os.Open(line[1])
|
includeFD, err := os.Open(line[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("ERROR(os.Open): %s\n", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = io.Copy(w, includeFD)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("ERROR(io.Copy): %s\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
io.Copy(w, includeFD)
|
|
||||||
includeFD.Close()
|
includeFD.Close()
|
||||||
} else {
|
} else {
|
||||||
_, err := w.WriteString(newLine + "\n")
|
_, err := w.WriteString(newLine + "\n")
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const LocalStateDir = "/var/warewulf"
|
const LocalStateDir = "/var/warewulf"
|
||||||
@@ -33,7 +34,6 @@ func vnfsBuild(vnfsPath string, wg *sync.WaitGroup) {
|
|||||||
fmt.Printf("ERROR: %s\n", err)
|
fmt.Printf("ERROR: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Printf("BUILD DONE: %s\n", vnfsPath)
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("SKIPPING VNFS: (bad path) %s\n", vnfsPath)
|
fmt.Printf("SKIPPING VNFS: (bad path) %s\n", vnfsPath)
|
||||||
@@ -43,7 +43,7 @@ func vnfsBuild(vnfsPath string, wg *sync.WaitGroup) {
|
|||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
fmt.Printf("USAGE: %s [vnfs/kernel/overlay/all]\n", os.Args[0])
|
fmt.Printf("USAGE: %s [vnfs/kernel/overlay] (node regex)\n", os.Args[0])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,15 +52,10 @@ func main() {
|
|||||||
set := make(map[string]bool)
|
set := make(map[string]bool)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
if len(os.Args) < 3 {
|
if len(os.Args) >= 3 {
|
||||||
fmt.Printf("USAGE: %s vnfs [node name pattern/ALL]\n", os.Args[0])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Args[2] == "ALL" {
|
|
||||||
nodeList, _ = assets.FindAllNodes()
|
|
||||||
} else {
|
|
||||||
nodeList, _ = assets.SearchByName(os.Args[2])
|
nodeList, _ = assets.SearchByName(os.Args[2])
|
||||||
|
} else {
|
||||||
|
nodeList, _ = assets.FindAllNodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nodeList) == 0 {
|
if len(nodeList) == 0 {
|
||||||
@@ -77,21 +72,18 @@ func main() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go vnfsBuild(entry, &wg)
|
go vnfsBuild(entry, &wg)
|
||||||
}
|
}
|
||||||
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
fmt.Printf("Waiting for build(s) to complete...\n")
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
} else if os.Args[1] == "kernel" {
|
} else if os.Args[1] == "kernel" {
|
||||||
var nodeList []assets.NodeInfo
|
var nodeList []assets.NodeInfo
|
||||||
set := make(map[string]bool)
|
set := make(map[string]bool)
|
||||||
|
|
||||||
if len(os.Args) < 3 {
|
if len(os.Args) >= 3 {
|
||||||
fmt.Printf("USAGE: %s vnfs [node name pattern/ALL]\n", os.Args[0])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Args[2] == "ALL" {
|
|
||||||
nodeList, _ = assets.FindAllNodes()
|
|
||||||
} else {
|
|
||||||
nodeList, _ = assets.SearchByName(os.Args[2])
|
nodeList, _ = assets.SearchByName(os.Args[2])
|
||||||
|
} else {
|
||||||
|
nodeList, _ = assets.FindAllNodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nodeList) == 0 {
|
if len(nodeList) == 0 {
|
||||||
@@ -140,15 +132,10 @@ func main() {
|
|||||||
var nodeList []assets.NodeInfo
|
var nodeList []assets.NodeInfo
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
if len(os.Args) < 3 {
|
if len(os.Args) >= 3 {
|
||||||
fmt.Printf("USAGE: %s vnfs [node name pattern/ALL]\n", os.Args[0])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Args[2] == "ALL" {
|
|
||||||
nodeList, _ = assets.FindAllNodes()
|
|
||||||
} else {
|
|
||||||
nodeList, _ = assets.SearchByName(os.Args[2])
|
nodeList, _ = assets.SearchByName(os.Args[2])
|
||||||
|
} else {
|
||||||
|
nodeList, _ = assets.FindAllNodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nodeList) == 0 {
|
if len(nodeList) == 0 {
|
||||||
@@ -157,7 +144,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, node := range nodeList {
|
for _, node := range nodeList {
|
||||||
|
|
||||||
replace := make(map[string]string)
|
replace := make(map[string]string)
|
||||||
replace["HOSTNAME"] = node.HostName
|
replace["HOSTNAME"] = node.HostName
|
||||||
replace["FQDN"] = node.Fqdn
|
replace["FQDN"] = node.Fqdn
|
||||||
@@ -174,8 +160,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
go overlayRuntime(node, replace, &wg)
|
overlayRuntime(node, replace, &wg)
|
||||||
go overlaySystem(node, replace, &wg)
|
overlaySystem(node, replace, &wg)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ func main() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
log.Printf("Updating runtime system\n")
|
log.Printf("Updating runtime system\n")
|
||||||
command := exec.Command("/bin/cpio", "-i")
|
command := exec.Command("/bin/cpio", "-iu")
|
||||||
command.Stdin = resp.Body
|
command.Stdin = resp.Body
|
||||||
err := command.Run()
|
err := command.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package assets
|
package assets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
// "os"
|
||||||
|
|
||||||
|
// "os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/errors"
|
"github.com/hpcng/warewulf/internal/pkg/errors"
|
||||||
@@ -11,7 +15,7 @@ import (
|
|||||||
const ConfigFile = "/etc/warewulf/nodes.conf"
|
const ConfigFile = "/etc/warewulf/nodes.conf"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
//TODO: Check to make sure nodes.yaml is found
|
//TODO: Check to make sure nodes.conf is found
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,12 +68,13 @@ func FindAllNodes() ([]NodeInfo, error) {
|
|||||||
var c nodeYaml
|
var c nodeYaml
|
||||||
var ret []NodeInfo
|
var ret []NodeInfo
|
||||||
|
|
||||||
fd, err := ioutil.ReadFile(ConfigFile)
|
data, err := ioutil.ReadFile(ConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Printf("error reading node configuration file\n")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = yaml.Unmarshal(fd, &c)
|
err = yaml.Unmarshal(data, &c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
1
overlays/runtime/default/etc/group.in
Normal file
1
overlays/runtime/default/etc/group.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#WWINCLUDE /etc/group
|
||||||
2
overlays/runtime/default/etc/passwd.in
Normal file
2
overlays/runtime/default/etc/passwd.in
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
root::0:0:root:/root:/bin/bash
|
||||||
|
#WWINCLUDE /etc/passwd
|
||||||
1
overlays/runtime/default/root/.ssh/authorized_keys.in
Normal file
1
overlays/runtime/default/root/.ssh/authorized_keys.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#WWINCLUDE /root/.ssh/authorized_keys
|
||||||
Reference in New Issue
Block a user