feat: 实现账号设备分组与命令日志

This commit is contained in:
Nixevol
2026-10-12 06:58:05 +08:00
parent ac68d4fe90
commit 775599174b
29 changed files with 3149 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/bin/sh
set -eu
umask 077
mkdir -p /data /secrets
secret=/secrets/nixmsg-admin-password
if [ ! -s "$secret" ]; then
set +e
out=$(/usr/local/bin/nixmsg admin init 2>&1)
code=$?
set -e
if [ "$code" -ne 0 ]; then
printf '%s\n' "$out" >&2
if printf '%s\n' "$out" | grep -q "already initialized"; then
echo "nixmsg admin already initialized but the password file is missing" >&2
exit 1
fi
exit "$code"
fi
pw=$(printf '%s\n' "$out" | sed -n 's/^admin password: //p' | head -n 1)
if [ -z "$pw" ]; then
echo "admin init did not print a password" >&2
exit 1
fi
printf '%s' "$pw" > "$secret"
echo "nixmsg admin initialized"
else
echo "nixmsg admin password file present"
fi
chown -R 65532:65532 /data /secrets
chmod 700 /secrets
chmod 600 "$secret"