11
Makefile
11
Makefile
@@ -142,6 +142,7 @@ files: all
|
||||
install -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/warewulf/
|
||||
install -d -m 0755 $(DESTDIR)$(SYSCONFDIR)/warewulf/ipxe
|
||||
install -d -m 0755 $(DESTDIR)$(TFTPDIR)/warewulf/ipxe/
|
||||
install -d -m 0755 $(DESTDIR)$(DATADIR)/warewulf/ipxe/
|
||||
install -d -m 0755 $(DESTDIR)$(BASH_COMPLETION)
|
||||
install -d -m 0755 $(DESTDIR)$(MANDIR)/man1
|
||||
install -d -m 0755 $(DESTDIR)$(FIREWALLDDIR)
|
||||
@@ -161,12 +162,10 @@ files: all
|
||||
install -c -m 0644 include/systemd/warewulfd.service $(DESTDIR)$(SYSTEMDDIR)
|
||||
cp bash_completion.d/warewulf $(DESTDIR)$(BASH_COMPLETION)
|
||||
cp man_pages/* $(DESTDIR)$(MANDIR)/man1/
|
||||
install -c -m 0644 staticfiles/arm64.efi $(DESTDIR)$(TFTPDIR)/warewulf
|
||||
install -c -m 0644 staticfiles/i386.efi $(DESTDIR)$(TFTPDIR)/warewulf
|
||||
install -c -m 0644 staticfiles/i386.kpxe $(DESTDIR)$(TFTPDIR)/warewulf
|
||||
install -c -m 0644 staticfiles/x86.efi $(DESTDIR)$(TFTPDIR)/warewulf
|
||||
|
||||
|
||||
install -c -m 0644 staticfiles/arm64.efi $(DESTDIR)$(DATADIR)/warewulf/ipxe
|
||||
install -c -m 0644 staticfiles/i386.efi $(DESTDIR)$(DATADIR)/warewulf/ipxe
|
||||
install -c -m 0644 staticfiles/i386.kpxe $(DESTDIR)$(DATADIR)/warewulf/ipxe
|
||||
install -c -m 0644 staticfiles/x86.efi $(DESTDIR)$(DATADIR)/warewulf/ipxe
|
||||
|
||||
init:
|
||||
systemctl daemon-reload
|
||||
|
||||
@@ -16,6 +16,7 @@ var (
|
||||
version string = "UNDEF"
|
||||
release string = "UNDEF"
|
||||
wwclientloc string = "UNDEF"
|
||||
datadir string = "UNDEF"
|
||||
)
|
||||
|
||||
func BINDIR() string {
|
||||
@@ -23,6 +24,11 @@ func BINDIR() string {
|
||||
return bindir
|
||||
}
|
||||
|
||||
func DATADIR() string {
|
||||
wwlog.Printf(wwlog.DEBUG, "DATADIR = '%s'\n", bindir)
|
||||
return datadir
|
||||
}
|
||||
|
||||
func SYSCONFDIR() string {
|
||||
wwlog.Printf(wwlog.DEBUG, "SYSCONFDIR = '%s'\n", sysconfdir)
|
||||
return sysconfdir
|
||||
|
||||
@@ -3,6 +3,7 @@ package buildconfig
|
||||
func init() {
|
||||
bindir = "@BINDIR@"
|
||||
sysconfdir = "@SYSCONFDIR@"
|
||||
datadir = "@DATADIR@"
|
||||
localstatedir = "@LOCALSTATEDIR@"
|
||||
srvdir = "@SRVDIR@"
|
||||
tftpdir = "@TFTPDIR@"
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/staticfiles"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -30,7 +29,7 @@ func configureTFTP(show bool) error {
|
||||
|
||||
fmt.Printf("Writing PXE files to: %s\n", tftpdir)
|
||||
for _, f := range [4]string{"x86.efi", "i386.efi", "i386.kpxe", "arm64.efi"} {
|
||||
err = staticfiles.WriteData(path.Join("files/tftp", f), path.Join(tftpdir, f))
|
||||
err = util.CopyFile(path.Join(buildconfig.DATADIR(), "warewulf", "ipxe", f), path.Join(tftpdir, f))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
return err
|
||||
|
||||
50
internal/pkg/util/copyfile.go
Normal file
50
internal/pkg/util/copyfile.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
func CopyFile(src string, dst string) error {
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Copying '%s' to '%s'\n", src, dst)
|
||||
|
||||
// Open source file
|
||||
srcFD, err := os.Open(src)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open source file %s: %s\n", src, err)
|
||||
return err
|
||||
}
|
||||
defer srcFD.Close()
|
||||
|
||||
// Confirm source file structure is readable
|
||||
_, err = srcFD.Stat()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not stat source file %s: %s\n", src, err)
|
||||
return err
|
||||
}
|
||||
|
||||
dstFD, err := os.Create(dst)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not create destination file %s: %s\n", dst, err)
|
||||
return err
|
||||
}
|
||||
defer dstFD.Close()
|
||||
|
||||
bytes, err := io.Copy(srcFD, dstFD)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "File copy from %s to %s failed.\n %s\n", src, dst, err)
|
||||
return err
|
||||
} else {
|
||||
wwlog.Printf(wwlog.DEBUG, "Copied %d bytes from %s to %s.\n", bytes, src, dst)
|
||||
}
|
||||
|
||||
err = CopyUIDGID(src, dst)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Ownership copy from %s to %s failed.\n %s\n", src, dst, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -73,37 +73,6 @@ func RandomString(n int) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func CopyFile(source string, dest string) error {
|
||||
wwlog.Printf(wwlog.DEBUG, "Copying '%s' to '%s'\n", source, dest)
|
||||
sourceFD, err := os.Open(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
finfo, err := sourceFD.Stat()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to stat source")
|
||||
}
|
||||
|
||||
destFD, err := os.OpenFile(dest, os.O_RDWR|os.O_CREATE, finfo.Mode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = io.Copy(destFD, sourceFD)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = CopyUIDGID(source, dest)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to set ownership")
|
||||
}
|
||||
sourceFD.Close()
|
||||
|
||||
return destFD.Close()
|
||||
}
|
||||
|
||||
func CopyFiles(source string, dest string) error {
|
||||
err := filepath.Walk(source, func(location string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user