Skip to content

fix(motd): compact SSH login layout for mobile - #109

Merged
LucaLin233 merged 4 commits into
mainfrom
forge/fix-compact-motd
Dec 2, 2026
Merged

LucaLin233 merged 4 commits into
mainfrom
forge/fix-compact-motd

Conversation

@LucaLin233

Copy link
Copy Markdown
Owner

Summary

把 SSH 登录 MOTD 的状态面板改成移动端优先的紧凑版式:主机/系统/已运行可在同一行、
负载/内存/根盘/CPU/内核各占一行、底部两行 上次登录/来源,并在明确列宽下使用 10 格
ASCII 进度条。列宽未知时(SSH PAM / run-parts 拿不到客户端宽度)兜底从旧 40 列改为 46 列。

Scope

  • tools/setup-motd.sh、modules/system-customize.sh:同一份 payload 同步修改,两份仍逐字节一致;
    保留既有采集、字段折行与安全安装/恢复链,只调整渲染布局、进度条格数与默认列宽。
  • 颜色统一为一套通用 ANSI:主机 1;32、来源 IP 1;34、资源数字 1;36、已用条 36、其余 39;
    无 truecolor、无固定 RGB、无背景填充;NO_COLOR、TERM=dumb 与 PAM 环境行为不变。
  • tests/test-motd.sh:更新过时的欢迎横幅/固定 RGB/40 列/块字符断言,新增 46 列兜底、
    窄版 6 格条、宽版 10 格条、显式 COLUMNS 31/32/40/80 与溢出回退断言;版式断言改用固定短主机名
    的稳定夹具,避免 CI 节点主机名长度影响 46 列合并行。
  • README.md:补充未知列宽兜底、显式 COLUMNS 优先、窄版说明与 ANSI 说明。

Validation

  • git diff --check 通过;bash -n 通过:tools/setup-motd.sh、modules/system-customize.sh、tests/test-motd.sh。
  • 提取出的 payload bash -n 通过;两份 payload cmp 一致,
    sha256 e2d54d505aa733acc768c2de5ae0b3261bf9388b19afc615206f960f33199af9。
  • 在测试目标机以真实 PTY 46 列(TIOCSWINSZ 46x30,无 SetEnv)登录,远端 stty size 回读 46x30:
    面板 6 行 + PAM 2 行,最宽行 40 列;主机/已运行同行、内核/架构同行、10 格 ASCII 条均成立,
    来源按 <IP> 脱敏记录。
  • 新版式断言片段本地全通过,stderr 为空。
  • 完整 CI(Ubuntu 24.04 lint and tests、Debian 13 tests)以本 PR 结果为准。

Risks

  • 46 列默认值来自 iPhone Termark 截图字宽估算(1320px、左缘约 37px、ASCII 步进约 27px),
    并非 PAM/run-parts 能读到的真实列宽;客户端更窄时会在字段边界折行,不丢内容、不缩字号。
  • 合并行只在放得下时发生,窄终端退回分行,行数会多于 46 列的紧凑形态。
  • 真实观感:深色真机已比对;浅色终端尚未实机验证。
  • 反显 # 见于真机截图,只读诊断归因到 zsh 的 PROMPT_EOL_MARK 提示符标记(zsh -f 可复现同序列,
    位于 PAM 两行之后),不是本 payload 输出;Termark 下为何保留在屏仍待确认,如需处理应在 shell 提示符侧。
  • 本 PR 只改脚本与文档,不涉及登录数据采集或安装事务逻辑。

Rollback

单个 squash 提交,git revert 即可回到当前 main 的布局与 40 列兜底;生产侧恢复使用既有
setup-motd.sh restore(组级快照,状态目录 /var/lib/linux-setup/motd-backups)。

FORGE and others added 4 commits December 1, 2026 23:04
Drop the fixed label column so the hostname opens the panel, compact
uptime to 3天4小时, keep the aligned resource bars and the closing rule,
and use one low-saturation ANSI palette that adapts to dark and light
terminals. Both entry points share the same payload and hash.
Read the release name and codename from os-release instead of pinning
Debian, drop the duplicated host check in the long-hostname loop, and
assert the resource zone by its fields so the Ubuntu shard passes.
@LucaLin233
LucaLin233 merged commit 483d505 into main Dec 2, 2026
16 checks passed
@LucaLin233
LucaLin233 deleted the forge/fix-compact-motd branch December 2, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant