From 629445631fef55c94cd9b81c0a1175d17f59f9bb Mon Sep 17 00:00:00 2001 From: smail Date: Thu, 15 Oct 2026 23:20:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Linux=20=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E9=85=8D=E7=BD=AE=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 安装器现在校验并安装 smail-config,同时补充对应的防回归测试。 --- backend/cmd/smail-admin/systemd_policy_test.go | 17 +++++++++++++++++ deploy/install-systemd.sh | 2 ++ 2 files changed, 19 insertions(+) diff --git a/backend/cmd/smail-admin/systemd_policy_test.go b/backend/cmd/smail-admin/systemd_policy_test.go index 66382f1..4bca547 100644 --- a/backend/cmd/smail-admin/systemd_policy_test.go +++ b/backend/cmd/smail-admin/systemd_policy_test.go @@ -96,6 +96,23 @@ func TestInstallerManagesProtectedEnvironmentFile(t *testing.T) { } } +func TestInstallerInstallsConfigurationTool(t *testing.T) { + root := filepath.Clean(filepath.Join("..", "..", "..")) + installer, err := os.ReadFile(filepath.Join(root, "deploy", "install-systemd.sh")) + if err != nil { + t.Fatal(err) + } + content := string(installer) + for _, required := range []string{ + "out/backend/smail-config_linux_$arch", + "install -o root -g root -m 0700 \"$root_dir/out/backend/smail-config_linux_$arch\" \"$runtime_dir/smail-config\"", + } { + if !strings.Contains(content, required) { + t.Fatalf("installer does not install smail-config: missing %q", required) + } + } +} + func TestInstallerRequiresExplicitFreshReset(t *testing.T) { root := filepath.Clean(filepath.Join("..", "..", "..")) installer, err := os.ReadFile(filepath.Join(root, "deploy", "install-systemd.sh")) diff --git a/deploy/install-systemd.sh b/deploy/install-systemd.sh index d3679d7..e9e5290 100644 --- a/deploy/install-systemd.sh +++ b/deploy/install-systemd.sh @@ -54,6 +54,7 @@ esac # 安装前先检查所有输入和运行状态,不能覆盖仍在运行的程序。 for file in "$root_dir/out/backend/smail_linux_$arch" "$root_dir/out/backend/smail-admin_linux_$arch" \ + "$root_dir/out/backend/smail-config_linux_$arch" \ "$root_dir/deploy/systemd/smail.service" "$root_dir/deploy/systemd/smail-admin.service"; do if [ ! -f "$file" ] || [ -L "$file" ] || [ ! -s "$file" ]; then echo "安装输入不存在或不是普通文件:$file" >&2 @@ -170,6 +171,7 @@ fi install -d -o root -g root -m 0755 /run/systemd/ask-password install -o root -g root -m 0755 "$root_dir/out/backend/smail_linux_$arch" "$runtime_dir/smail" install -o root -g root -m 0700 "$root_dir/out/backend/smail-admin_linux_$arch" "$runtime_dir/smail-admin" +install -o root -g root -m 0700 "$root_dir/out/backend/smail-config_linux_$arch" "$runtime_dir/smail-config" install -o root -g root -m 0644 "$root_dir/deploy/systemd/smail.service" /etc/systemd/system/smail.service install -o root -g root -m 0644 "$root_dir/deploy/systemd/smail-admin.service" /etc/systemd/system/smail-admin.service systemctl daemon-reload