feat(Agent): 修复裸机安装配置

This commit is contained in:
Awuqing
2026-05-01 16:41:10 +08:00
parent 91d26bb92a
commit 81a239d3d5
10 changed files with 137 additions and 75 deletions

View File

@@ -37,19 +37,22 @@ func TestRenderScriptBashBootstrap(t *testing.T) {
}
}
func TestRenderScriptCreatesBackupXUserAndGroup(t *testing.T) {
func TestRenderScriptUsesRootForBareMetalBackups(t *testing.T) {
got, err := RenderScript(testCtx)
if err != nil {
t.Fatalf("render err: %v", err)
}
for _, want := range []string{
"getent group backupx",
"groupadd --system backupx",
"useradd --system --gid backupx",
"Group=backupx",
"/var/lib/backupx-agent/tmp",
"install -d -m 0700 /var/lib/backupx-agent /var/lib/backupx-agent/tmp",
} {
if !strings.Contains(got, want) {
t.Errorf("script missing %q:\n%s", want, got)
}
}
for _, forbidden := range []string{"User=backupx", "Group=backupx", "NoNewPrivileges=true"} {
if strings.Contains(got, forbidden) {
t.Errorf("script should not contain %q for bare-metal backups:\n%s", forbidden, got)
}
}
}