agent fix 12-19-25
This commit is contained in:
parent
46637f6759
commit
d46a64a41e
@ -2,7 +2,6 @@ package node
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"zlh-agent/internal/provision/executil"
|
||||
"zlh-agent/internal/provision/markers"
|
||||
@ -16,14 +15,10 @@ func Install(cfg state.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
scriptPath := filepath.Join(
|
||||
executil.ScriptsRoot,
|
||||
"devcontainer",
|
||||
"node",
|
||||
"install.sh",
|
||||
)
|
||||
|
||||
if err := executil.RunScript(scriptPath); err != nil {
|
||||
// Execute embedded installer (mirrors game server model)
|
||||
if err := executil.RunEmbeddedScript(
|
||||
"scripts/devcontainer/node/install.sh",
|
||||
); err != nil {
|
||||
return fmt.Errorf("node devcontainer install failed: %w", err)
|
||||
}
|
||||
|
||||
|
||||
28
internal/provision/executil/embedded_exec.go
Normal file
28
internal/provision/executil/embedded_exec.go
Normal file
@ -0,0 +1,28 @@
|
||||
package executil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"zlh-agent/scripts"
|
||||
)
|
||||
|
||||
// RunEmbeddedScript executes an embedded script via bash by piping its contents to stdin.
|
||||
// This mirrors RunScript's stdout/stderr behavior without requiring any files on disk.
|
||||
func RunEmbeddedScript(path string) error {
|
||||
data, err := scripts.FS.ReadFile(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("embedded script not found: %s", path)
|
||||
}
|
||||
|
||||
cmd := exec.Command("bash")
|
||||
cmd.Stdin = bytes.NewReader(data)
|
||||
|
||||
// Match RunScript behavior (executil.go)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
6
scripts/assets.go
Normal file
6
scripts/assets.go
Normal file
@ -0,0 +1,6 @@
|
||||
package scripts
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed *.sh
|
||||
var ScriptsFS embed.FS
|
||||
Loading…
Reference in New Issue
Block a user