Add a better file copy.

This commit is contained in:
root 2025-03-18 20:34:51 -04:00
parent d04f652831
commit 1262869fcc

14
main.go
View file

@ -11,6 +11,7 @@ import (
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"dario.cat/mergo" "dario.cat/mergo"
"github.com/otiai10/copy"
) )
type Config struct { type Config struct {
@ -135,7 +136,7 @@ func main() {
for _, f := range s.ConfigFiles { for _, f := range s.ConfigFiles {
f := strings.Split(f, ":") f := strings.Split(f, ":")
// Read service template file // Read service config template file
fp := fmt.Sprintf("services/%s/%s", name, f[0]) fp := fmt.Sprintf("services/%s/%s", name, f[0])
t, err := os.ReadFile(fp) t, err := os.ReadFile(fp)
if err != nil { if err != nil {
@ -233,16 +234,7 @@ func main() {
// Copy any mandatory configuration files over before continuing. // Copy any mandatory configuration files over before continuing.
// TODO: This will be replaced with a full copy later. // TODO: This will be replaced with a full copy later.
{ {
var err error err := copy.Copy("/config/etc", "/etc")
os.Remove("/etc/apk/world")
err = os.Link("/config/etc/apk/world",
"/etc/apk/world")
if err != nil { fmt.Println(err) }
os.Remove("/etc/caddy/CaddyFile")
err = os.Link("/config/etc/caddy/Caddyfile",
"/etc/caddy/CaddyFile")
if err != nil { fmt.Println(err) } if err != nil { fmt.Println(err) }
} }