scripts: support OpenRC and other non-systemd init systems (make systemd-run optional) #84

Closed
github-bot wants to merge 5 commits from github-bot/gh-84 into main AGit
Owner

@⁠dim-ghub on GitHub · 2026-12-01 17:52 UTC · original
dim-ghub:main → main · +256 −3 · 6 files · 5 commits · closed without merging

Summary

`setup.sh`, `build.sh`, and `run.sh` previously had a hard dependency on `systemd-run`,      
preventing them from running on OpenRC and other non-systemd Linux systems.

### Changes

- **`env.sh`**: Added `run_scoped` (and `_mem_bytes`) to handle memory-capped execution      
across init systems:
  1. Uses `systemd-run --user --scope` when systemd and its user manager are available       
  (preserving existing behavior on systemd).
  2. Falls back to a transient cgroup v2 directory (`memory.high`, `memory.max`,             
  `memory.swap.max`) when a delegated cgroup with the `memory` controller is writable        
  (auto-detected from `/proc/self/cgroup` or configured via `VICTORY_CGROUP_DIR`), forwarding
  `INT`/`TERM` and cleaning up on exit.
  3. Otherwise logs a short note and runs the command directly via `exec "$@"`.
- **`setup.sh`**: Removed `systemd-run` from the required tools check in `step_tools`.       
- **`build.sh`**: Replaced `exec systemd-run ...` with `run_scoped`.
- **`run.sh`**: Replaced `exec systemd-run ...` with `run_scoped`.

### Testing

- Verified syntax with `bash -n` on `env.sh`, `setup.sh`, `build.sh`, and `run.sh`.          
- Tested on Artix Linux (OpenRC): verified `_mem_bytes` unit parsing, `run_scoped` fallback  
and exit-code propagation, non-cgroupfs `VICTORY_CGROUP_DIR` cleanup/fallback, and the       
`setup.sh` tool check.
**@⁠dim-ghub** on GitHub · 2026-12-01 17:52 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/84) `dim-ghub:main` → `main` · +256 −3 · 6 files · 5 commits · closed without merging ### Summary `setup.sh`, `build.sh`, and `run.sh` previously had a hard dependency on `systemd-run`, preventing them from running on OpenRC and other non-systemd Linux systems. ### Changes - **`env.sh`**: Added `run_scoped` (and `_mem_bytes`) to handle memory-capped execution across init systems: 1. Uses `systemd-run --user --scope` when systemd and its user manager are available (preserving existing behavior on systemd). 2. Falls back to a transient cgroup v2 directory (`memory.high`, `memory.max`, `memory.swap.max`) when a delegated cgroup with the `memory` controller is writable (auto-detected from `/proc/self/cgroup` or configured via `VICTORY_CGROUP_DIR`), forwarding `INT`/`TERM` and cleaning up on exit. 3. Otherwise logs a short note and runs the command directly via `exec "$@"`. - **`setup.sh`**: Removed `systemd-run` from the required tools check in `step_tools`. - **`build.sh`**: Replaced `exec systemd-run ...` with `run_scoped`. - **`run.sh`**: Replaced `exec systemd-run ...` with `run_scoped`. ### Testing - Verified syntax with `bash -n` on `env.sh`, `setup.sh`, `build.sh`, and `run.sh`. - Tested on Artix Linux (OpenRC): verified `_mem_bytes` unit parsing, `run_scoped` fallback and exit-code propagation, non-cgroupfs `VICTORY_CGROUP_DIR` cleanup/fallback, and the `setup.sh` tool check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 17:53:34 +00:00
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 12:03 UTC · original

The goal is right and someone has to land it — but not this version, and there is a better base open today (#337, 267 lines, docs and a real shell test, clean merge).

Two blockers here:

  • env.sh:126 and env.sh:138 write the parent script's $BASHPID into $cg_dir/cgroup.procs as well as the child's. The launching shell then lives under the same memory.max as the game: double-counted against the cap, and it can be OOM-killed mid-run, taking the log and the cleanup with it.
  • tools/install-cgroup-scope.sh:22 installs /etc/sudoers.d/victory-cgroup with NOPASSWD: on a root-owned helper. A permanent root-escalation path shipped for a build-script convenience is something the maintainer should refuse outright.

Also: VICTORY_CGROUP_DIR (env.sh:98) is in neither docs/SETTINGS.md nor run.conf.default, the PR touches no docs at all (docs/BUILD.md:14 still lists systemd-run as required, :71 still says it runs under systemd-run --user), and there are no tests.

If you want to keep the cgroup attach as an option, it should be a follow-up to the smaller PR, without the root helper and without putting the launcher under the cap.

**@⁠Luxuride** on GitHub · 2026-12-04 12:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/84#issuecomment-7410914411) The goal is right and someone has to land it — but not this version, and there is a better base open today (`#337`, 267 lines, docs and a real shell test, clean merge). Two blockers here: - `env.sh:126` and `env.sh:138` write the **parent script's `$BASHPID`** into `$cg_dir/cgroup.procs` as well as the child's. The launching shell then lives under the same `memory.max` as the game: double-counted against the cap, and it can be OOM-killed mid-run, taking the log and the cleanup with it. - `tools/install-cgroup-scope.sh:22` installs `/etc/sudoers.d/victory-cgroup` with `NOPASSWD:` on a root-owned helper. A permanent root-escalation path shipped for a build-script convenience is something the maintainer should refuse outright. Also: `VICTORY_CGROUP_DIR` (`env.sh:98`) is in neither `docs/SETTINGS.md` nor `run.conf.default`, the PR touches no docs at all (`docs/BUILD.md:14` still lists `systemd-run` as required, `:71` still says it runs under `systemd-run --user`), and there are no tests. If you want to keep the cgroup attach as an option, it should be a follow-up to the smaller PR, without the root helper and without putting the launcher under the cap.
github-bot closed this pull request 2026-12-05 17:31:50 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.