Commit bf36321
Add root-ubuntu.sh: provision an Ubuntu/Debian server from one file
Moves the server provisioner out of the private dotfiles repo and into
cli-tools, where it can be curled onto a box that has nothing on it yet.
It is the odd one out here -- bash rather than TypeScript, and not linked
onto PATH -- because it has to run before Node exists.
Three things had to change for it to live in a public repo and work on a
machine that is not one of ours.
Dotfiles are now optional and are not in this repository. They cannot be:
a dotfiles tree carries ssh config, known_hosts and sometimes keys. The
script used to die unless it was sitting inside that checkout, which is
exactly what stopped it running anywhere else. It now resolves a source
in order -- DOTFILES_DIR, the directory holding the script, DOTFILES_REPO
cloned to a cache, or nothing -- and skips only the dotfile stages when
there is none. install_ssh had to be split for this: authorising the
account's own key is not a dotfiles job, and an earlier cut of this
returned early without one, so accounts got created that could not log in.
Nothing identifying anybody is left in it. ACME_EMAIL has no default,
because a made-up address sends a stranger's certificate warnings into a
black hole, and certbot is passed --register-unsafely-without-email
rather than an empty -m. There is no default ad slot: a slot id is an
account, so shipping one bills every box that ever runs this to whoever
owns it. Credentials come from the environment or the config file only.
Configuration is read, not sourced. The environment has to win over the
file, and `.` assigns unconditionally, so a sourced config would quietly
beat the value someone just put on the command line -- and this runs as
root, where sourcing hands a config file the whole machine. It is
KEY=value, parsed, with nothing executed. Not JSON, because the script
runs before apt has installed jq.
Also: a POSIX guard that says so in one sentence when the script is run
under sh, since /bin/sh on Ubuntu is dash and the old one-liner would
have failed on the first [[ with a syntax error naming a line nobody
typed; an OS check that warns rather than refuses; --groups, so accounts
can be provisioned from a pipe; and the landing page still recognises the
marker from when this lived in the dotfiles repo, without which every
already-provisioned box would decide its own page was hand-edited and
never touch it again.
34 tests cover the pure helpers by cutting them out of the file and
running them in a real bash, plus the invariants that make it safe to
publish: no personal identifiers, no key material, no default slot.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 1fca2bf commit bf36321
5 files changed
Lines changed: 4438 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
683 | 689 | | |
684 | 690 | | |
685 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
686 | 769 | | |
687 | 770 | | |
688 | 771 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments