#!/bin/sh # Usage: eac-run COMMAND [ARGS...] # Runs COMMAND (a game launcher) with what Easy Anti-Cheat needs on OpenRC, and only for as long # as it runs: systemd-run-agent for the user, and the socket-activate.easyanticheat_eos listener, # started through pkexec (no password for the active local session, see the polkit action). [ $# -gt 0 ] || { echo "usage: eac-run COMMAND [ARGS...]" >&2; exit 2; } lib=/usr/libexec/eac-openrc-compat name=easyanticheat_eos svc=socket-activate.$name running() { rc-service "$svc" status >/dev/null 2>&1; } at_boot() { rc-update show default 2>/dev/null | grep -qwF "$svc"; } "$lib/systemd-run-agent" 2>/dev/null & agent=$! was_running= running && was_running=1 # Before EAC's first install the binary is missing; its setup then starts the listener itself. if [ -z "$was_running" ] && [ -x /usr/local/bin/easyanticheat_eos ]; then pkexec "$lib/socket-activate-ctl" start "$name" >/dev/null || echo "eac-run: could not start $svc" >&2 fi cleanup() { if [ -z "$was_running" ] && running && ! at_boot; then pkexec "$lib/socket-activate-ctl" stop "$name" >/dev/null fi kill "$agent" 2>/dev/null } trap cleanup EXIT trap 'exit 130' INT TERM HUP "$@"