Keep the files for the server in one directory
The resources were copied from home/ and admin/, which held the same files a second time. Everything that goes to the server is in resources/ now, and the generator only writes the four text files. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
a17b2d76dc
commit
fd1e379fcf
6 changed files with 13 additions and 69 deletions
|
|
@ -62,18 +62,16 @@ undoes that.
|
|||
|
||||
## This directory
|
||||
|
||||
- `home/` - the files that belong in the home directory of the user: `~/.zshrc`, `~/.zshenv` and the keys in
|
||||
`~/.ssh/authorized_keys` - the one the website logs in with and the ones of the people who deploy. This is where
|
||||
they are edited.
|
||||
- `admin/` - the same for the home directory of the Administrator: the keys of the people who deploy. The key of the
|
||||
website is not among them and never gets administrator rights.
|
||||
- `resources/` - the copies the cleanup restores from: the files of `home/` and `admin/` and the four text files.
|
||||
- `scripts/make_files.py` - builds the resources.
|
||||
- `resources/` - everything that goes to the server: `home/` for the home directory of the root user - `~/.zshrc`,
|
||||
`~/.zshenv`, the keys in `~/.ssh/authorized_keys` and the four text files - and `admin/` for the home directory
|
||||
of the Administrator, which holds the keys of the people who deploy. The key of the website is not among them and
|
||||
never gets administrator rights.
|
||||
- `scripts/make_files.py` - builds the four text files.
|
||||
- `scripts/deploy.sh` - deploys the cleanup to the server and installs it.
|
||||
- `scripts/install_restore_task.ps1` - installs the scheduled task.
|
||||
- `scripts/restore_ssh_access.cmd` - puts the SSH access back, for when the home directory was deleted.
|
||||
|
||||
The resources are built from the website's pages and the files of `home/`:
|
||||
The four text files are built from the website's pages, the other files in the resources are edited by hand:
|
||||
|
||||
python3 server/scripts/make_files.py
|
||||
|
||||
|
|
@ -85,7 +83,7 @@ The script logs in as `Administrator` - whose shell is a Windows one - copies th
|
|||
Administrator's home directory and runs the installer there. It logs in with the personal key of the deployer, from
|
||||
the agent or from `-i`; the key of the website never gets administrator rights, it only logs in as the root user.
|
||||
It checks the host key against the one the website pins, and that the key of the website is the first one in
|
||||
`home/.ssh/authorized_keys`. `--uninstall` removes the task again.
|
||||
`resources/home/.ssh/authorized_keys`. `--uninstall` removes the task again.
|
||||
|
||||
The installer can also be run by hand, in an elevated PowerShell on the server:
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIBTHzLm8QMhHIo7kFAvtAFnqpspeR3L3gM8kLoG1137 lennart@erms
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJDweEH8bhZAHVaAedhTVDb2j/oMEn3vm97xCwCw9LC9 root@nowhere.wirs.ing cygwin-2222
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIBTHzLm8QMhHIo7kFAvtAFnqpspeR3L3gM8kLoG1137 lennart@erms
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Preset what MSYS2's /etc/profile would otherwise start a helper process for (~90 ms each here).
|
||||
# TZ has to match the Windows timezone (W. Europe Standard Time).
|
||||
export LANG=en_US.UTF-8 TZ=Europe/Berlin
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
# 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 is a native Windows program; winpty lets it draw in the pty, as Server 2016 has no ConPTY.
|
||||
alias btm='winpty /ucrt64/bin/btm'
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
# Builds the files for the home directories of the shell server in ../resources: the home of the root user with
|
||||
# README, README.en, CODE_OF_CONDUCT and CODE_OF_CONDUCT.en as the website's pages in terminal text with escape
|
||||
# sequences, and the files of ../home and ../admin, which are copied as they are.
|
||||
# Builds the text files for the home directory of the shell server's root user in ../resources/home: README,
|
||||
# README.en, CODE_OF_CONDUCT and CODE_OF_CONDUCT.en as the website's pages in terminal text with escape sequences.
|
||||
# The other files there are edited by hand.
|
||||
# Usage: python3 server/scripts/make_files.py
|
||||
import pathlib
|
||||
import shutil
|
||||
import textwrap
|
||||
|
||||
ESC = '\x1b'
|
||||
|
|
@ -331,19 +330,8 @@ COC_EN = {
|
|||
'footer': [('Home', f'{SITE}en.html'), ('Legal notice', IMPRESSUM)],
|
||||
}
|
||||
|
||||
out = pathlib.Path(__file__).parent.parent / 'resources'
|
||||
(out / 'home').mkdir(parents=True, exist_ok=True)
|
||||
out = pathlib.Path(__file__).parent.parent / 'resources' / 'home'
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
for name, text in [('README', readme(DE)), ('README.en', readme(EN)),
|
||||
('CODE_OF_CONDUCT', code_of_conduct(COC_DE)), ('CODE_OF_CONDUCT.en', code_of_conduct(COC_EN))]:
|
||||
(out / 'home' / name).write_text(text, encoding='utf-8')
|
||||
# The files of the home directories are not generated, they are copied from ../home and ../admin, where they are
|
||||
# edited.
|
||||
for source in 'home', 'admin':
|
||||
root = pathlib.Path(__file__).parent.parent / source
|
||||
for path in root.rglob('*'):
|
||||
target = out / source / path.relative_to(root)
|
||||
if path.is_dir():
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
else:
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(path, target)
|
||||
(out / name).write_text(text, encoding='utf-8')
|
||||
|
|
|
|||
Loading…
Reference in a new issue