agent fix 12-19-25
This commit is contained in:
parent
46637f6759
commit
d46a64a41e
@ -2,7 +2,6 @@ package node
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"zlh-agent/internal/provision/executil"
|
"zlh-agent/internal/provision/executil"
|
||||||
"zlh-agent/internal/provision/markers"
|
"zlh-agent/internal/provision/markers"
|
||||||
@ -16,14 +15,10 @@ func Install(cfg state.Config) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptPath := filepath.Join(
|
// Execute embedded installer (mirrors game server model)
|
||||||
executil.ScriptsRoot,
|
if err := executil.RunEmbeddedScript(
|
||||||
"devcontainer",
|
"scripts/devcontainer/node/install.sh",
|
||||||
"node",
|
); err != nil {
|
||||||
"install.sh",
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := executil.RunScript(scriptPath); err != nil {
|
|
||||||
return fmt.Errorf("node devcontainer install failed: %w", err)
|
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