Skip to content

feat(scripts): Linux systemd support for maintain.sh#36

Open
abdout wants to merge 2 commits into
feat/bootstrap-shfrom
feat/linux-systemd
Open

feat(scripts): Linux systemd support for maintain.sh#36
abdout wants to merge 2 commits into
feat/bootstrap-shfrom
feat/linux-systemd

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented May 16, 2026

Summary

Closes the last cross-platform gap — Linux now has scheduling parity. maintain.sh picks the right backend (launchd on macOS, systemd --user on Linux), so bootstrap.sh step 15 works everywhere without OS-specific branching.

What's in the PR

  • ~/.claude/scripts/maintain.sh — OS detection, dual-backend install/uninstall/status
  • ~/.claude/scripts/bootstrap.sh — drops the 'Linux not supported' warning at step 15

How it picks the backend

OS Backend What gets written
macOS launchd ~/Library/LaunchAgents/com.databayt.kun-maintain.plist (loaded via launchctl)
Linux systemd --user ~/.config/systemd/user/kun-maintain.{service,timer} (enabled via systemctl --user enable --now)
Linux without systemd error exit 5 with hint to use cron manually

systemd timer detail

[Timer]
OnCalendar=*-*-* 09:00:00
Persistent=true     # catches missed runs after sleep — same behavior as launchd
Unit=kun-maintain.service

[Install]
WantedBy=timers.target

--status output examples

macOS:

kun-maintain status
  Backend:  launchd
  State:    loaded
  Plist:    /Users/.../Library/LaunchAgents/com.databayt.kun-maintain.plist

Linux:

kun-maintain status
  Backend:  systemd --user
  State:    enabled
  Next run: Mon 2026-05-17 09:00:00 UTC

Test plan

  • bash -n maintain.sh passes
  • bash -n bootstrap.sh passes
  • bash maintain.sh --status on this Windows machine (Git Bash) correctly degrades — neither macOS nor Linux branch fires
  • Real Linux: maintain.sh --install writes service + timer, systemctl --user list-timers shows it
  • Real Linux: maintain.sh --uninstall disables + removes; idempotent
  • Real macOS: unchanged behavior (existing launchd path)

Dependencies

Stacks on feat/bootstrap-sh (PR #35). Final merge order:

#29 → #30 → #31 → #32 → #33 → #34 → #35 → this PR → #25

🤖 Generated with Claude Code

Closes the cross-platform scheduling gap. macOS uses launchd
(existing); Linux now uses systemd --user units. bootstrap.sh
step 15 no longer warns 'Linux not supported' — it just calls
maintain.sh --install and the script handles the backend choice.

maintain.sh changes:
- OS detection sets IS_MAC / IS_LINUX flags at top
- --install branches: macOS writes ~/Library/LaunchAgents/com.databayt.kun-maintain.plist;
  Linux writes ~/.config/systemd/user/kun-maintain.{service,timer}
  and runs 'systemctl --user enable --now kun-maintain.timer'
- --uninstall branches similarly
- --status shows 'Backend: launchd' or 'Backend: systemd --user'
  with 'Next run' from 'systemctl --user list-timers' on Linux
- systemd timer uses OnCalendar=*-*-* HH:MM:00 + Persistent=true
  (catches missed runs after laptop sleep, same as launchd)
- Graceful degradation: systemctl missing → exit 5 with hint to use cron

bootstrap.sh changes:
- Step 15 no longer branches on IS_LINUX — delegates to maintain.sh

bash -n syntax-clean. Linux systemd validation needs a Linux machine.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kun Ready Ready Preview, Comment May 16, 2026 5:29pm

Both sync-repos.ps1 and sync-repos.sh printed 'Cloned successfully'
unconditionally after 'git clone', ignoring the exit code. Surfaced
on a real bootstrap run: hogwarts appeared to clone (the log said
'Cloned successfully'), but the directory wasn't on disk afterward.
git clone had failed partway through with no error surfaced.

- PowerShell: check $LASTEXITCODE and Test-Path before claiming success
- Bash: use 'if git clone …' so the success branch only fires on exit 0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant