37 lines
1.9 KiB
Bash
37 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
for dir in /var/lib/dshs/users/*/; do
|
|
[ -d "$dir" ] || continue
|
|
id="$(basename "$dir")"
|
|
[ "$id" = . ] && continue
|
|
short="$(echo "$id" | tr -d '-' | cut -c1-20)"
|
|
user="dsh-$short"
|
|
if ! id "$user" &>/dev/null; then
|
|
uid="$(node /opt/dshs/lib/cli.js uid-for-user "$id" --db /var/lib/dshs/dshs.db 2>/dev/null || echo 0)"
|
|
[ "$uid" = 0 ] && { echo "SKIP $id (uid-for-user失败)"; continue; }
|
|
# 若该uid已被其他账号占用则跳过
|
|
if id "$uid" &>/dev/null; then echo "SKIP $id (uid $uid 已被占用)"; continue; fi
|
|
useradd -u "$uid" -M -s /usr/sbin/nologin "$user"
|
|
echo "created $user (uid $uid) for $id"
|
|
fi
|
|
uid="$(id -u "$user")"
|
|
chown -R "$uid:$uid" "$dir"
|
|
echo "provisioned $id -> uid $uid"
|
|
done
|
|
|
|
# 2026-09-11 追加(档案 18 v3 收尾):为该批新用户补齐「目录选择器收敛」——
|
|
# ① 安装受限插件(逐用户 pnpm add)② 写平台段(cordis.patch.yml,幂等)。
|
|
# best-effort:失败不影响上面的账号 provisioning;日志见 journalctl -u dsh-provision。
|
|
if [ -f /opt/dshs/poc/workspace-scoped-picker/ensure-workspace-picker.cjs ]; then
|
|
node /opt/dshs/poc/workspace-scoped-picker/ensure-workspace-picker.cjs 2>&1 | sed "s/^/[picker] /" || true
|
|
fi
|
|
|
|
# 2026-09-11 追加:「设置面板 → 用户管理」入口(@dsh-local/portal-entry)全员兜底。
|
|
# 该插件提供设置面板最后一个分区「用户管理」(管理员=门户地址+打开管理台+退出登录;
|
|
# 普通用户=仅退出登录)。**普通用户没有它就没有任何退出登录入口**,故必须与新用户
|
|
# 注册同步补齐(与上面的 picker 同一时机、同一 best-effort 策略)。
|
|
# 幂等:按 node_modules 已装版本 + dep spec 判定,已是最新即跳过。
|
|
if [ -f /opt/dshs/scripts/ensure-portal-entry.cjs ]; then
|
|
node /opt/dshs/scripts/ensure-portal-entry.cjs 2>&1 | sed "s/^/[portal-entry] /" || true
|
|
fi
|