Files
chandra/scripts/as-root
T
Claude 3e35c4dfa5
CI / test (push) Successful in 2m25s
One install recipe: just install installs everything
just install now builds as you, then asks for root once and installs the
whole thing: the login session (wasm compositor on the MoonBit host,
modules, chandra-ctl, KDE colors, portal) and face unlock (helper, PAM
module, config, models). The alternatives are flags instead of recipes:
--link (was install-dev), --rust (install-rust), --native
(install-native), --pam (install-face --pam), --no-face, --no-models.
The PAM module is compiled as you into build/, so root only copies it;
without a compiler or libpam headers face unlock is skipped with a warning.
just uninstall removes face unlock too (--purge: enrolled faces).

Removed: install-dev, install-rust, install-native, install-face,
uninstall-face and the old install-session* / uninstall-session aliases.
New docs/install.md; README, docs and installer hints updated. Also drops
a committed __pycache__ file and ignores __pycache__/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkA52AocBmJHipFRqb
2026-11-26 01:38:58 +00:00

26 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# Run one command as root with whatever this system uses for that: run0 (systemd 256+), else
# sudo, doas, or pkexec. Used by `just install` and `just uninstall`.
#
# scripts/as-root python3 session/install.py
#
# run0 starts the command as a transient systemd service: it does not inherit our environment
# (PATH included; only TERM and a few others get through) and it looks the program up in the
# service manager's own PATH. So the program is resolved to an absolute path here first, which
# also makes tools that are only on our PATH (pixi, ~/.moon/bin) work. The working directory is
# kept (run0 keeps it when the target user is root), so relative paths in the arguments are fine.
set -e
[ $# -gt 0 ] || { echo "usage: scripts/as-root COMMAND [ARG...]" >&2; exit 2; }
prog=$(command -v "$1") || { echo "as-root: $1: not found" >&2; exit 127; }
shift
[ "$(id -u)" = 0 ] && exec "$prog" "$@"
# CHANDRA_AS_ROOT picks the tool (run0, sudo, doas or pkexec) instead of the first one found.
for tool in ${CHANDRA_AS_ROOT:-run0 sudo doas pkexec}; do
command -v "$tool" >/dev/null 2>&1 || continue
# run0 needs systemd as PID 1 (and systemd 256+); on other inits fall through to sudo/doas.
[ "$tool" = run0 ] && [ ! -d /run/systemd/system ] && continue
exec "$tool" "$prog" "$@"
done
echo "as-root: none of run0, sudo, doas or pkexec is available; run this as root: $prog $*" >&2
exit 1