xonecas.io
8356
Wx

www-xonecas-io / commit effd320

make login-shell lets git push <you>@<host>:<name>.git reach the site from your own account (1042) (1048)

login-shell.sh sends pushes, clones of <name>.git and remote to bin/site, and everything else
to your own shell. README and help show it in place of the git user's setup.

Co-Authored-By: Claude Opus 5.5

Sean Caetano Martin2026-11-08 effd3203a5f25ca25a496d8131f5794a7346f6c3 parent 2ec11b6

8 files changed

Makefile+12−1
@@ -1,7 +1,7 @@
11 TAILWIND_VERSION := v4.3.3
22 REPOS ?= repos
33
4-.PHONY: site import index serve test
4+.PHONY: site import index serve test login-shell
55
66 bin/tailwindcss:
77 mkdir -p bin
@@ -24,3 +24,14 @@ serve: bin/tailwindcss
2424
2525 test:
2626 go test ./...
27+
28+# login-shell makes git push <you>@<this host>:<name>.git reach the site. Run it once, on the server, in the site folder,
29+# as the user that owns it. Your logins, ssh commands, scp and sftp still get your own shell, LOGIN_SHELL.
30+LOGIN ?= /usr/local/bin/site-login
31+LOGIN_SHELL ?= $(shell getent passwd $(USER) | cut -d: -f7)
32+login-shell: site
33+ @test "$(LOGIN_SHELL)" != "$(LOGIN)" || { echo "already set up; to redo it, pass your own shell: make login-shell LOGIN_SHELL=/bin/bash"; exit 1; }
34+ sed -e 's|@SITE@|$(CURDIR)/bin/site|' -e 's|@SHELL@|$(LOGIN_SHELL)|' login-shell.sh | sudo tee $(LOGIN) >/dev/null
35+ sudo chmod 755 $(LOGIN)
36+ grep -qx $(LOGIN) /etc/shells || echo $(LOGIN) | sudo tee -a /etc/shells >/dev/null
37+ sudo chsh -s $(LOGIN) $(USER)
README.md+13−12
@@ -4,7 +4,7 @@ My projects and their git history, as a site. `site serve` reads the git repos a
44 for, with htmx swapping pages in place of full reloads. It also serves `git clone` of every project at `/<name>.git`.
55
66 ```
7- git push over SSH ─► git's shell ─► repos/xonecas.io/<name>.git ─┐
7+ git push over SSH ─► login-shell ─► repos/xonecas.io/<name>.git ─┐
88 ├─► site index ─► data/projects.json ─► site serve
99 sources.txt ─► site import ─► repos/<host>/<owner>/<repo>.git ───┤
1010 overrides.txt ──┘
@@ -23,33 +23,34 @@ Run everything from this folder. `bin/site help` lists the commands, and `bin/si
2323
2424 ## Push a repo from anywhere
2525
26-Pushing over SSH creates the repo on its first push, the way `gh repo create` would, and each push updates the site.
27-**Once, on the server:** make `bin/site` the login shell of the user pushes go to. Here that's `git`, with this repo at `~git/site`
28-and `make site` run there:
26+You push to your own account on the server, with its password or any key. The first push creates the repo, the way
27+`gh repo create` would, and each push updates the site.
28+
29+**Once, on the server,** in the site folder, as the user that owns it:
2930
3031 ```sh
31-echo /home/git/site/bin/site | sudo tee -a /etc/shells
32-sudo chsh -s /home/git/site/bin/site git
32+make login-shell
3333 ```
3434
35-sshd then runs `site -c <command>` however `git` logs in, with its password or any key in `~git/.ssh/authorized_keys`.
36-It allows only `git push`, `git clone`/`fetch` of hosted repos and `remote`, and never gives a shell.
35+It makes `login-shell.sh` your login shell. Pushes and clones of `<name>.git`, and `remote`, go to `bin/site`. Everything
36+else (your logins, ssh commands, scp, sftp) still gets your own shell, and a repo that already exists in your home is
37+pushed to as before. To undo it: `sudo chsh -s /bin/bash $USER`.
3738
3839 **Then, from any machine:**
3940
4041 ```sh
41-git remote add origin git@xonecas.io:my-thing.git
42+git remote add origin sean@xonecas.io:my-thing.git # or: git remote set-url origin ...
4243 git push -u origin main
43-ssh git@xonecas.io remote list # remote new|add|rm work the same way
44+ssh sean@xonecas.io remote list # remote new|add|rm work the same way
4445 ```
4546
46-If it says `does not appear to be a git repository`, you logged in as a user whose shell isn't `bin/site`.
47+If it says `does not appear to be a git repository`, `make login-shell` hasn't run on the server for that user.
4748
4849 ## Manage repos
4950
5051 | To | Run |
5152 | --- | --- |
52-| Start a repo the site hosts | `git push` to `git@xonecas.io:my-thing.git`, or `remote new my-thing` first, which prints that URL |
53+| Start a repo the site hosts | `git push` to `sean@xonecas.io:my-thing.git`, or `remote new my-thing` first, which prints that URL |
5354 | Show a repo you already have | `bin/site remote add ~/code/other-thing` (a path) or `bin/site remote add https://host/owner/repo.git` |
5455 | Stop showing a repo | `bin/site remote rm <path or url>` (a hosted repo's data is kept) |
5556 | List the repos | `bin/site remote list` |
cmd/site/help.go+4−6
@@ -19,19 +19,17 @@ Site
1919 site import fetch every added remote again
2020 site index read the repos into data/projects.json
2121 site serve serve the site on :8080, from the repos and data/projects.json
22- site -c <command> what sshd runs when site is the git user's shell: git push, git clone and remote
22+ site -c <command> what login-shell runs for git push, git clone and remote
2323
2424 site <command> -h a command's flags
2525
2626 Set up pushing, once, on the server
27- Make site the login shell of the user pushes go to (git here), with the site folder at ~git/site:
28- echo /home/git/site/bin/site | sudo tee -a /etc/shells && sudo chsh -s /home/git/site/bin/site git
29- Then log in as git with its password or any key in ~git/.ssh/authorized_keys.
27+ make login-shell in the site folder, as the user that owns it; README.md says what it changes
3028
3129 Push a new repo, from any machine
32- git remote add origin git@xonecas.io:my-thing.git
30+ git remote add origin sean@xonecas.io:my-thing.git
3331 git push -u origin main the first push creates the repo; each push updates the site
34- ssh git@xonecas.io remote list the same remote commands, over SSH
32+ ssh sean@xonecas.io remote list the same remote commands, over SSH
3533
3634 Show a repo you already have
3735 bin/site remote add ~/code/other-thing
cmd/site/main.go+3−10
@@ -2,7 +2,7 @@
22 //
33 // site import [-sources sources.txt] [-store repos] [-jobs 8] [-meta data/meta.json]
44 // site remote [-sources sources.txt] [-store repos] [-meta data/meta.json] list | new <name> | add <url or path> | rm <url or path>
5-// site -c <command>, run by sshd when site is the git user's login shell
5+// site -c <command>, run by the login shell from make login-shell for git push, git clone and remote
66 // site index [-sources sources.txt] [-store repos] [-overrides overrides.txt] [-meta data/meta.json] [-out data/projects.json]
77 // site serve [-data data/projects.json] [-tailwind bin/tailwindcss] [-addr :8080] [-devnotes]
88 package main
@@ -54,19 +54,12 @@ func main() {
5454 log.Fatal(err)
5555 }
5656 case "-c":
57- // site is the git user's login shell, so sshd runs site -c <command> for a password or any key.
57+ // The login shell from make login-shell runs site -c <command> for git push, git clone and remote.
5858 if len(os.Args) != 3 {
5959 printUsage(os.Stderr, nil)
6060 os.Exit(2)
6161 }
62- exe, err := os.Executable()
63- if err == nil {
64- err = os.Chdir(filepath.Dir(filepath.Dir(exe))) // the site folder, from <site>/bin/site
65- }
66- if err == nil {
67- err = shell(os.Args[2], "sources.txt", "repos", "data/meta.json")
68- }
69- if err != nil {
62+ if err := shell(os.Args[2]); err != nil {
7063 log.Fatal(err)
7164 }
7265 case "index":
cmd/site/remote.go+1−1
@@ -16,7 +16,7 @@ import (
1616
1717 // remote lists the remotes in the sources file, or adds, removes or creates one.
1818 // add mirrors a remote and refreshes the hosts' metadata, as import does. new makes a repo the site
19-// hosts, to push to over SSH; each push rebuilds the site. rm deletes a mirror, but keeps a hosted repo.
19+// hosts, to push to over SSH; each push updates the site. rm deletes a mirror, but keeps a hosted repo.
2020 func remote(args []string, sources, root, meta string) error {
2121 urls, err := store.Sources(sources)
2222 if err != nil {
cmd/site/shell.go+41−12
@@ -6,6 +6,7 @@ import (
66 "log"
77 "os"
88 "os/exec"
9+ "path/filepath"
910 "slices"
1011 "strings"
1112 "syscall"
@@ -13,13 +14,22 @@ import (
1314 "xonecas.io/site/internal/store"
1415 )
1516
16-// shell runs one SSH command for the site, as the git user's login shell (site -c <command>).
17-// git push to <name>.git creates the repo on its first push, git clone and fetch read it,
18-// and remote manages the repos, as site remote does. Nothing else runs, so the user gets no shell.
19-func shell(cmd, sources, root, meta string) error {
17+// shell runs one SSH command that the login shell from make login-shell hands the site (site -c <command>).
18+// git push to <name>.git creates the repo on its first push, git clone and fetch read it, and remote
19+// manages the repos, as site remote does. A path with a / or one that exists in the user's home isn't
20+// the site's, so git gets it as sshd would have.
21+func shell(cmd string) error {
2022 args := strings.Fields(cmd)
2123 if len(args) == 2 && (args[0] == "git-receive-pack" || args[0] == "git-upload-pack") {
22- name := strings.TrimSuffix(strings.TrimLeft(strings.Trim(args[1], "'"), "/~"), ".git")
24+ path := strings.Trim(args[1], "'")
25+ if rel := strings.TrimPrefix(path, "~/"); strings.Contains(rel, "/") || exists(rel) {
26+ return execGit(args[0], path)
27+ }
28+ if err := chdirSite(); err != nil {
29+ return err
30+ }
31+ const sources, root, meta = "sources.txt", "repos", "data/meta.json"
32+ name := strings.TrimSuffix(strings.TrimPrefix(path, "~/"), ".git")
2333 url := hostedURL(name)
2434 urls, err := store.Sources(sources)
2535 if err != nil {
@@ -32,16 +42,35 @@ func shell(cmd, sources, root, meta string) error {
3242 if err := newRepo(name, urls, sources, root, meta); err != nil {
3343 return err
3444 }
35- log.Printf("created %s; each push rebuilds the site", url)
45+ log.Printf("created %s; each push updates the site", url)
3646 }
37- git, err := exec.LookPath("git")
38- if err != nil {
47+ return execGit(args[0], store.Dir(root, url))
48+ }
49+ if len(args) > 0 && args[0] == "remote" {
50+ if err := chdirSite(); err != nil {
3951 return err
4052 }
41- return syscall.Exec(git, []string{"git", strings.TrimPrefix(args[0], "git-"), store.Dir(root, url)}, os.Environ())
53+ return remote(args[1:], "sources.txt", "repos", "data/meta.json")
4254 }
43- if len(args) > 0 && args[0] == "remote" {
44- return remote(args[1:], sources, root, meta)
55+ return errors.New("usage: git push <user>@<host>:<name>.git, git clone it, or ssh <user>@<host> remote list | new <name> | add <path or url> | rm <path or url>")
56+}
57+
58+func exists(path string) bool { _, err := os.Stat(path); return err == nil }
59+
60+// chdirSite moves to the site folder, bin/site's parent.
61+func chdirSite() error {
62+ exe, err := os.Executable()
63+ if err != nil {
64+ return err
65+ }
66+ return os.Chdir(filepath.Dir(filepath.Dir(exe)))
67+}
68+
69+// execGit replaces site with git-receive-pack or git-upload-pack on dir.
70+func execGit(verb, dir string) error {
71+ git, err := exec.LookPath("git")
72+ if err != nil {
73+ return err
4574 }
46- return errors.New("usage: git push git@<host>:<name>.git, git clone it, or ssh git@<host> remote list | new <name> | add <path or url> | rm <path or url>")
75+ return syscall.Exec(git, []string{"git", strings.TrimPrefix(verb, "git-"), dir}, os.Environ())
4776 }
login-shell.sh+8−0
@@ -0,0 +1,8 @@
1+#!/bin/sh
2+# The login shell make login-shell gives the site's user. git push and clone of <name>.git, and remote,
3+# go to the site; everything else (a login, ssh commands, scp, sftp) goes to the user's own shell.
4+case $1:$2 in
5+-c:"git-receive-pack '"* | -c:"git-upload-pack '"* | -c:remote | -c:"remote "*) exec @SITE@ -c "$2" ;;
6+esac
7+[ $# -eq 0 ] && exec @SHELL@ -l # a script's $0 never has the login dash, but only a login starts it with no arguments
8+exec @SHELL@ "$@"
tickets/1048-why-didn-t-we-use-htmx.md+14−2
@@ -5,10 +5,10 @@ type: feature
55 status: review
66 priority: p2
77 created: 2026-11-08T20:45:24Z
8-updated: 2026-11-08T21:09:21Z
8+updated: 2026-11-08T21:19:22Z
99 source: human
1010 area: site
11-moves: 2026-11-08T20:50:15Z inbox todo drag; 2026-11-08T20:52:44Z todo doing drag; 2026-11-08T21:09:21Z doing review agent
11+moves: 2026-11-08T20:50:15Z inbox todo drag; 2026-11-08T20:52:44Z todo doing drag; 2026-11-08T21:09:21Z doing review agent; 2026-11-08T21:18:11Z review todo note; 2026-11-08T21:18:16Z todo doing drag; 2026-11-08T21:19:22Z doing review agent
1212 ---
1313
1414 Serve the site from a Go server and use htmx on every page. The site should feel like a current web app, not a set of static pages.
@@ -100,3 +100,15 @@ Why: in 1002 xonecas picked "Go, with htmx and Tailwind as the starting point".
100100 - Repos created before this change still run 'site build' after 'site index' in their post-receive hook. Index runs, then build fails with the usage text in build.log. 1047 owns the hook.
101101 - 1046 (panic with no shown project) now hits 'site serve'.
102102 - The login-shell changes in Makefile, README, cmd/site/main.go, help.go and shell.go, and login-shell.sh, were uncommitted when I started. I left them out of this commit, and they're still in the working tree.
103+
104+- 2026-11-08 21:18Z (human): Are they important and required? if so you should commit them. Use basic common sense.
105+
106+- 2026-11-08 21:19Z (agent): Yes, they matter, so they're committed now, in their own commit. They finish 1042: 'make login-shell' makes your own account (sean@) the push target, instead of a separate git user. Without them, the committed README and help describe the old git-user setup, and a push to sean@ fails the way 1042's last note says.
107+
108+ What's in it: login-shell.sh, the login-shell target in the Makefile, shell.go, and the matching README, help and main.go lines. I also changed two log and doc lines from 'each push rebuilds the site' to 'updates', since 1048 removed the build.
109+
110+ CHECKED, with the login shell built from login-shell.sh and a fake ssh, nothing changed on the system:
111+ - In a throwaway site folder, a push to x:throwaway-thing.git created the repo and added it to sources.txt. Its hook ran only 'site index'. A clone of it over SSH got the commit.
112+ - 'remote list' went to site. A plain command and a login went to bash. A path repo in the home went to plain git.
113+ - go vet and go test pass.
114+ NOT CHECKED: 'make login-shell' itself. It runs sudo chsh, and I didn't change this VM's login shell.