File debian.postinst of Package sing-box-ref1nd
#!/bin/sh
set -e
case "$1" in
configure)
# 优先使用 systemd-sysusers 创建系统用户
if [ -d /run/systemd/system ] && [ -x /usr/bin/systemd-sysusers ]; then
systemd-sysusers sing-box.conf
else
# fallback: 手动创建系统用户(非 systemd 系统)
if ! getent passwd sing-box >/dev/null; then
adduser --system --group --no-create-home --home /nonexistent \
--gecos "Sing-box Service" sing-box
fi
fi
# 创建状态目录
mkdir -p /var/lib/sing-box
chown sing-box:sing-box /var/lib/sing-box
chmod 750 /var/lib/sing-box
;;
esac
#DEBHELPER#
exit 0