修复 Linux 部署缺少配置工具
安装器现在校验并安装 smail-config,同时补充对应的防回归测试。
This commit is contained in:
parent
2e87b106d2
commit
629445631f
@ -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) {
|
func TestInstallerRequiresExplicitFreshReset(t *testing.T) {
|
||||||
root := filepath.Clean(filepath.Join("..", "..", ".."))
|
root := filepath.Clean(filepath.Join("..", "..", ".."))
|
||||||
installer, err := os.ReadFile(filepath.Join(root, "deploy", "install-systemd.sh"))
|
installer, err := os.ReadFile(filepath.Join(root, "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" \
|
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
|
"$root_dir/deploy/systemd/smail.service" "$root_dir/deploy/systemd/smail-admin.service"; do
|
||||||
if [ ! -f "$file" ] || [ -L "$file" ] || [ ! -s "$file" ]; then
|
if [ ! -f "$file" ] || [ -L "$file" ] || [ ! -s "$file" ]; then
|
||||||
echo "安装输入不存在或不是普通文件:$file" >&2
|
echo "安装输入不存在或不是普通文件:$file" >&2
|
||||||
@ -170,6 +171,7 @@ fi
|
|||||||
install -d -o root -g root -m 0755 /run/systemd/ask-password
|
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 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-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.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
|
install -o root -g root -m 0644 "$root_dir/deploy/systemd/smail-admin.service" /etc/systemd/system/smail-admin.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user