On 6 Nov a visitor deleted the whole MSYS2 installation, the locked /etc/passwd included, and the site was down for a week: the cleanup job repaired the runtime with pacman, which was gone too, and never tried to start the server again because a port-22 query without results counted as a failed query. The installer now builds a pristine installation from the official base archive (hash pinned) and the site's packages in the administrators' folder. Everything the SYSTEM server trusts comes from there and is kept in place and locked by the cleanup job: opt/kik, the runtime, passwd, group, nsswitch.conf, fstab, fstab.d and etc/ssh. The user gets modify rather than full control, so locked files can no longer be deleted, and the folders leading to them cannot be renamed. When pacman is gone the job copies the missing files back from the pristine installation. Nothing that runs as SYSTEM or Administrator runs a file the user can write any more: the job ran /usr/bin/pacman.exe as SYSTEM, the installer ran ldd and pacman from the installation, the Administrator's shell was a cmdshell.exe in /usr/local/bin, and the Administrator's sessions searched /usr/bin for programs. The Administrator's shell is PowerShell now, and deploy.sh speaks it. server/scripts/rdp.sh opens a headless remote desktop session for when SSH is down. The shell finds the CLANG64 programs and runs helix through winpty. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
43 lines
2.2 KiB
Shell
43 lines
2.2 KiB
Shell
# The protected copies of zsh and cat (and the server itself) live here; keeping them first means the basic
|
|
# journey - the prompt and reading the four texts - survives even if the user breaks their own /usr/bin copies.
|
|
path=(/opt/kik $path)
|
|
# Programs of MSYS2's CLANG64 environment (pacman -S mingw-w64-clang-x86_64-...), after the MSYS2 ones.
|
|
path+=/clang64/bin
|
|
|
|
# History shared between sessions.
|
|
HISTFILE=~/.zsh_history HISTSIZE=10000 SAVEHIST=10000
|
|
setopt share_history hist_ignore_dups hist_ignore_space interactive_comments auto_cd
|
|
|
|
# Completion: menu, case-insensitive, colored. -C skips compaudit, which is slow on
|
|
# Windows and meaningless under MSYS2's noacl mounts (rm ~/.zcompdump after adding completions).
|
|
autoload -Uz compinit && compinit -C
|
|
zstyle ':completion:*' menu select
|
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
|
|
|
# Emacs keys; Up/Down search history for what is already typed.
|
|
bindkey -e
|
|
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search && zle -N down-line-or-beginning-search
|
|
bindkey '^[[A' up-line-or-beginning-search '^[OA' up-line-or-beginning-search
|
|
bindkey '^[[B' down-line-or-beginning-search '^[OB' down-line-or-beginning-search
|
|
|
|
# Prompt: user@host:directory, git branch, exit status of the last command if it failed.
|
|
# A literal '#' as on Linux: zsh's %# would show '%', since this root is not uid 0.
|
|
# The branch is read from .git/HEAD directly: starting git on every prompt is slow on Windows.
|
|
precmd() {
|
|
local d=$PWD head=
|
|
until [[ -e $d/.git || $d == / ]]; do d=${d:h}; done
|
|
[[ -f $d/.git/HEAD ]] && read -r head < $d/.git/HEAD
|
|
[[ $head == 'ref: '* ]] && git_branch=${head#ref: refs/heads/} || git_branch=${head:0:7}
|
|
print -Pn '\e]0;%n@%m: %~\a'
|
|
}
|
|
setopt prompt_subst
|
|
PROMPT='%F{green}%n@%m%f:%F{blue}%~%f${git_branch:+ %5F($git_branch)%f}%(?.. %F{red}[%?]%f)# '
|
|
|
|
alias ls='ls --color=auto' ll='ls -lah' grep='grep --color=auto'
|
|
|
|
# Process monitor: htop does not exist for MSYS2 (its /proc only shows MSYS2 processes).
|
|
# bottom and helix are native Windows programs; winpty lets them draw in the pty and read the keys, as Server 2016
|
|
# has no ConPTY.
|
|
alias btm='winpty /ucrt64/bin/btm' hx='winpty /clang64/bin/hx'
|