Files
webui4frpc/packaging/deb/postinst
JianFeeeee ee46b758fa feat(packaging): 单元与安装包改为配置文件启动,口令不再写入 ExecStart
所有交付形态统一成「只传 -config」,凭据留在配置文件 / secrets 文件里。

- systemd 单元:ExecStart 改为 `-config /etc/webui4frpc/config.json`,
  EnvironmentFile 加 `-` 前缀变成可选;新增 ReadOnlyPaths=-/etc/webui4frpc/secret。
- 新增 packaging/common/config.json 示例:口令默认用
  file:/etc/webui4frpc/secret/password 引用,内嵌以 "_" 开头的说明键。
- webui4frpc.env 瘦身为可选环境变量(${VAR} 取值来源),不再承载明文口令。
- deb/rpm:安装 config.json 与 0750 的 secret 目录,config.json 进 conffiles,
  安装后提示改成「设置 password 文件」。
- release.sh 的分发单元模板同步改 -config;tar.gz 附 config.json.example。
- macOS pkg:写 config.json + secret/password,launch 包装脚本只传 -config。
- Windows NSIS:安装时把口令写进 secret-password.txt(icacls 限制为
  SYSTEM/Administrators),生成 data/config.json 用 file: 引用,启动脚本只传
  -config;顺带按 JSON 规则转义 addr/user。makensis 实测可编译通过。
2026-10-23 09:12:30 +08:00

54 lines
1.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# webui4frpc deb/rpm 安装后脚本:建用户、建目录、装服务
set -e
if ! getent group webui4frpc >/dev/null 2>&1; then
groupadd --system webui4frpc
fi
if ! getent passwd webui4frpc >/dev/null 2>&1; then
useradd --system --gid webui4frpc \
--home-dir /var/lib/webui4frpc --no-create-home \
--shell /usr/sbin/nologin \
--comment "webui4frpc service account" webui4frpc
fi
mkdir -p /var/lib/webui4frpc
chown -R webui4frpc:webui4frpc /var/lib/webui4frpc
chmod 750 /var/lib/webui4frpc
chown root:webui4frpc /etc/webui4frpc/webui4frpc.env 2>/dev/null || true
chmod 640 /etc/webui4frpc/webui4frpc.env 2>/dev/null || true
# Startup config + the directory that holds the admin password file.
# The service reads /etc/webui4frpc/config.json (see the unit's ExecStart), so
# the password never has to appear on the command line. secret/ is root-writable
# and group-readable by the service account; files inside are created by the
# admin, we only fix ownership/permissions of the directory itself.
mkdir -p /etc/webui4frpc/secret
chown root:webui4frpc /etc/webui4frpc/secret 2>/dev/null || true
chmod 750 /etc/webui4frpc/secret 2>/dev/null || true
chmod 644 /etc/webui4frpc/config.json 2>/dev/null || true
if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload || true
systemctl enable webui4frpc.service || true
if [ -z "${DPKG_ROOT:-}" ]; then
systemctl restart webui4frpc.service || true
fi
fi
cat <<'EOF'
webui4frpc 已安装。
配置: /etc/webui4frpc/config.json (请设置 password,推荐 file:/etc/webui4frpc/secret/password)
密钥: echo '你的口令' > /etc/webui4frpc/secret/password && chmod 0640 /etc/webui4frpc/secret/password
数据: /var/lib/webui4frpc
服务: systemctl status webui4frpc
界面: http://<本机地址>:7500
改完配置后执行: systemctl restart webui4frpc
EOF
exit 0