Repository navigation
Add omarchy-server uninstall - #10
Conversation
There was no way to remove Omarchy Server. The new command takes it off the machine and keeps the user's data by default, as discussed on issue MyOwnDataCenter#5. omarchy-server uninstall [--purge] [-y] Default: stops and disables the three user services and removes their unit files, the launcher entries, the top-bar icon, the omarchy-server command (only if it is our link), the storage helper and its sudoers rule, the firewall rules the installer added, and the program folder. The account, apps and their data, machines and their disks stay, so installing again picks up where it left off. Apps and machines that are still running are listed, because they keep running. --purge: also deletes the data folder. It refuses, and changes nothing, while any app (a compose project named omarchy-*) or machine (a libvirt session domain named omarchy-*) still exists, so those go through the web app first. It also refuses when podman or libvirt is installed but cannot answer, because "could not ask" must never be read as "nothing there". App folders are removed with `podman unshare rm -rf`, as the server does, because they can belong to the apps' own user ids. Apps are found from podman's JSON output (the compose project label), because the text of `podman ps --format` differs between podman versions: a first version that indexed .Labels in a template failed on podman 6.1.4 in a test VM. It asks the user to type "uninstall" (or "delete" for --purge) unless -y is given, and refuses to run without a terminal and without -y. It never touches the user's files, ~/Pools, the installed packages or the linger setting. test/uninstall.test.mjs runs the real script in a temporary home folder with stand-ins for sudo, systemctl, ufw, podman and virsh that only record what they were asked. It fails if the command is missing, if --purge stops refusing, if --purge guesses when podman or libvirt cannot answer, or if the default run touches the data folder. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01BXN1v3McRXvDta1mtsKJkR
MyOwnDataCenter
left a comment
There was a problem hiding this comment.
Thank you for this. It's careful, thorough work. The design is what we agreed on in #5: data kept by default, --purge for everything, a typed confirmation. Your testing on a throwaway VM (a real leftover project and domain, files owned by app user ids, a reinstall afterwards) is exactly what something that deletes data needs. Every path matches what install.sh creates, including --data $BASE/omarchyd.
Not merging yet, only because of two things that need fixing first. Both are small.
1. Two of the new tests fail anywhere node isn't in /usr/bin. The tests run the script with PATH: ${box.bin}:/usr/bin:/bin, and leftovers() runs node -e. On GitHub's runners (and my machine) Node lives elsewhere (/opt/node22/bin/node here), so node isn't found:
- "uninstall leaves a command that is not ours alone…" doesn't list
app: nextcloud; - "--purge refuses while apps or machines still exist…" goes ahead instead of refusing.
Adding ${dirname(process.execPath)} to those PATHs makes all 8 pass.
2. --purge can delete app data while apps still exist (this one matters). The same failure in real use: if node isn't on the PATH of the shell running the command (for example, Node installed through mise or nvm and not loaded in that shell), leftovers() quietly finds no apps and --purge deletes everything. I reproduced it: with a podman that reports omarchy-demo and no node on PATH, uninstall --purge -y printed "Omarchy Server and its data are gone." and the data folder was deleted. That breaks the rule you set yourself (rightly): couldn't ask must never count as nothing there.
Suggested fix: have can_ask also require command -v node whenever podman is installed, and give that case a test. Alternatively, have leftovers() report failure (exit non-zero) when the parse can't run, and refuse on that.
Smaller things, not blocking, but worth a look while you're in there:
- sudo failures: with
-yand no terminal, thesudosteps fail silently (output goes to/dev/null), and the script still says it's removed while the helper and/etc/sudoers.d/omarchy-serverstay. Saying "couldn't remove the storage helper; runsudo rm …" would be clearer. - Leftovers outside the installer's rules: the firewall rules for individual app ports (
comment 'Omarchy Server app', added by the helper'sfirewall-open) and the shares rule for 445 aren't removed, and nor are any SMB share settings. For the default mode that's arguably right, since apps stay; for--purgeit might be worth listing them. - Thanks for flagging the
askHiddenpaste problem inomarchyd/cli.mjs. I'll fix that separately.
Once 1 and 2 are in, I'll rerun everything and merge. Thanks again, this is a really solid feature.
Generated by Claude Code
- omarchyd used <data>/tls while the web server used ~/.local/share/ omarchy-server/tls, so app gateways served a certificate from a different authority than the one devices trust, and Security settings (always https, replace certificate) only reached omarchyd. omarchyd/cli.mjs now passes defaultTlsDir(); an "always https" choice from the old folder is carried over. - omarchyd/prompt.mjs: the create-owner prompt reads input character by character, so a pasted password with its Enter (or both passwords at once) works (reported by nixfred in #10). - cloudUserData ignores a non-list `commands` (noted by nixfred in #9). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011b9fuB8ePE7DYtvvqNj1s2
|
Quick follow-up on the side note: thanks again for reporting the password-paste problem. It's fixed on main in 41385a4. The prompt now reads input one character at a time, so a password pasted with its Enter, or both passwords pasted at once, works. Checked with a real terminal: the old prompt hangs, the new one creates the account. The review points above still stand; I'm looking forward to the update. Generated by Claude Code |
… could not run Review on the pull request found two things, both fixed here. 1. --purge reads podman's answer with node. If node is not on the PATH of the shell running the command (node from mise or nvm that is not loaded there), leftovers() quietly found no apps and --purge went ahead and deleted app data. can_ask now also requires node whenever podman is installed, so "could not ask" still counts as "do not delete". The tests now build their PATH from where node really is (the two that failed wherever node is not in /usr/bin), and a new test runs --purge with a podman that reports an app and no node on the PATH: it must refuse and change nothing. 2. With -y and no terminal the sudo steps failed silently and the script still said it was done, leaving the storage helper and /etc/sudoers.d/omarchy-server. The root steps now run only when sudo can work (sudo -n, or a terminal to type a password in). Otherwise the user-level parts are still removed, the exact sudo commands to run by hand are printed, and the exit code is 1. A sudo command that fails is reported the same way. Also from the review: --purge now says that firewall rules for individual app ports and any SMB shares are not removed, and where to look. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01BXN1v3McRXvDta1mtsKJkR
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01BXN1v3McRXvDta1mtsKJkR
|
Thank you for the careful review. Both blocking points are fixed in the new commit on this branch (main is merged in too).
From the smaller notes: with Checked on this branch on top of main: type check, build and the full suite (149 tests) pass. I also broke each fix on purpose and confirmed a test fails. Thanks for the quick fix to the password prompt, and for crediting the report. |
|
Thank you. This update addressed everything, and the way you verified it (breaking each fix on purpose to see a test fail, and repeating my reproduction on the VM with real podman) is exactly the care a command that deletes data needs. Accepted and merged. It ships in 0.9.15 with a What's New entry crediting you. What I checked before merging, on this branch on top of the latest main:
One thought for later, not a problem with this change: This closes #5. Thanks again for seeing it through. Generated by Claude Code |
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_011b9fuB8ePE7DYtvvqNj1s2
What this changes
Adds
omarchy-server uninstall [--purge] [-y], as discussed on #5.omarchy-servercommand (only if it is our link), the storage helper and its sudoers rule, the firewall rules the installer added, and the program folder. The account, apps and their data, and machines and their disks stay, so installing again picks up where you left off. Apps and machines that are still running are listed, because they keep running.--purge: also deletes the data folder. It refuses, and changes nothing, while any app (compose projectomarchy-*) or machine (libvirt session domainomarchy-*) still exists, and also when podman or libvirt is installed but cannot answer. App folders go throughpodman unshare rm -rf, as the server does, because they can belong to the apps' own user ids.uninstall(ordelete) unless-yis given, and refuses to run without a terminal and without-y. It never touches your files,~/Pools, the installed packages or the "run while logged out" setting.How you tested it
npm run typecheck,npm run buildandnpm testpass (132 tests, 8 of them new intest/uninstall.test.mjs, which runs the real script in a temporary home with stand-ins forsudo,systemctl,ufw,podmanandvirsh). I broke the command on purpose three ways (no command,--purgenot refusing, default run wiping the data folder) and each makes a test fail.pacman -Syu, installed withinstall.shfrom this branch, firewall on):--purge -ywith a real leftover compose project and a real libvirt domain: refused, named both, nothing changed (machine state before and after identical).uninstall: services, unit files, port 7780, command, launchers, program folder, helper, sudoers rule, all 8 firewall rules and the top-bar icon gone. Account, apps and machines data kept; the leftover app and machine untouched; an unrelated firewall rule kept;shell.jsonstill valid.accounts.jsonbyte for byte the same, machine state identical to the first install.--purgewith app files owned by uid 100004, where a plainrm -rffails with permission denied: removed throughpodman unshare, data folder gone,~/Poolskept.Anything to know
.Labelsin apodman ps --formattemplate, which errors on podman 6.1.4. Because errors were hidden,--purgewould have read that as "no apps". The VM caught it; apps are now read from podman's JSON, and--purgerefuses when it cannot ask.widget offleavesshell.json.omarchy-server.bakbehind (existing behaviour, not changed here).omarchyd/cli.mjs(askHidden) compares each chunk of input with\r, so a password pasted together with its Enter is taken as password text,\rincluded, and the prompt keeps waiting. I hit it while scripting the VM install.Closes #5
🤖 Generated with Claude Code
https://claude.ai/code/session_01BXN1v3McRXvDta1mtsKJkR