feat: 🎉 complete maker nginx(app)

This commit is contained in:
zhaoyupeng
2025-11-26 21:03:41 +08:00
parent 4ec58ce4e5
commit 11523e3e48
26 changed files with 1458 additions and 6 deletions

View File

@@ -1,8 +1,39 @@
package controller
package installer
import (
"context"
"errors"
"os/exec"
"gitea.loveuer.com/yizhisec/pkg3/logger"
)
type installer struct {
target string
}
func NewInstaller() *installer {
return &installer{}
func (i *installer) targetOK(ctx context.Context) error {
if i.target == "" {
logger.Debug("🎯 installer.targetOK: target = self")
return nil
}
// run ssh <target>, check if it's reachable, and it's root user
cmd := exec.CommandContext(ctx, "ssh", i.target, "whoami")
output, err := cmd.CombinedOutput()
if err != nil {
logger.Debug("❌ installer.targetOK: check target %s failed, err = %v", i.target, err)
return err
}
if string(output) != "root\n" {
logger.Debug("❌ installer.targetOK: check target %s failed, output = %s", i.target, string(output))
return errors.New("target is not root user")
}
return nil
}
func NewInstaller(target string) *installer {
return &installer{target: target}
}