Files
fabolous005 95954b2d6b Prepare for publication: license, disclaimer, limitations, kernel 7.3.7, polkit action rename
- LICENSE: ebuilds GPL-2.0-only (LICENSE.GPL-2), everything else MIT.
- README: unofficial/no-affiliation and account-risk disclaimer; requirements
  and limitations (NVIDIA/ZFS/r8125 EAC modules not packaged, keys, ESP,
  one tested machine).
- AGENTS.md: the values table is the author's example machine.
- progress: CachyOS's key is on Epic's trusted list (was wrong).
- overlay: kernel 7.3.7_p2 with module cleanup, compat -r3 (polkit action
  de.root64.engler-labs.eac-openrc-compat), pkgcheck fixes.
2026-12-04 09:13:45 +01:00

66 lines
2.2 KiB
Bash

#!/bin/bash
# systemctl for OpenRC hosts (eac-openrc-compat). A unit NAME.socket or NAME.service is handled
# when the OpenRC service socket-activate.NAME exists; everything else fails as on a host that
# was not booted with systemd. Every call is logged to syslog.
logger -t systemctl-compat -- "uid=$EUID: $*" 2>/dev/null
nosystemd() {
echo "System has not been booted with systemd as init system (PID 1). Can't operate." >&2
echo "Failed to connect to system scope bus via local transport: Host is down" >&2
exit 1
}
cmd= now= quiet= units=()
for a; do
case $a in
--version) echo "systemd 257 (257-eac-openrc-compat)"; exit 0 ;;
--now) now=1 ;;
-q|--quiet) quiet=1 ;;
--system|--no-block|--no-pager|--no-reload|--no-ask-password|--full|-l) ;;
-*) nosystemd ;;
*) if [[ -z $cmd ]]; then cmd=$a; else units+=("$a"); fi ;;
esac
done
case $cmd in
daemon-reload|daemon-reexec) exit 0 ;;
'') nosystemd ;;
esac
svc= kinds=()
for u in "${units[@]}"; do
[[ $u == *.* ]] || u+=.service
s=socket-activate.${u%.*}
[[ -e /etc/init.d/$s && ( -z $svc || $svc == "$s" ) ]] || nosystemd
svc=$s
kinds+=("${u##*.}")
done
[[ -n $svc ]] || nosystemd
only_service=1
for k in "${kinds[@]}"; do [[ $k == service ]] || only_service=; done
out() { [[ -n $quiet ]] || echo "$@"; }
rc() { if [[ -n $quiet ]]; then rc-service "$@" >/dev/null; else rc-service "$@"; fi; }
case $cmd in
start) rc -N "$svc" start ;;
restart|try-restart|reload-or-restart) rc "$svc" restart ;;
# Stopping only the service keeps the socket listening: restart the listener, which ends its child.
stop) if [[ -n $only_service ]]; then rc -s "$svc" restart; else rc -s "$svc" stop; fi ;;
reset-failed) exit 0 ;;
enable)
rc-update add "$svc" default >/dev/null || exit
[[ -z $now ]] || rc -N "$svc" start ;;
disable)
rc-update del "$svc" default >/dev/null 2>&1
[[ -z $now ]] || rc -s "$svc" stop ;;
is-enabled)
if [[ -n $only_service ]]; then out static; exit 0; fi
if rc-update show default | grep -qwF "$svc"; then out enabled; else out disabled; exit 1; fi ;;
is-active)
if rc-service "$svc" status >/dev/null 2>&1; then out active; else out inactive; exit 3; fi ;;
status) rc-service "$svc" status ;;
*) echo "systemctl (eac-openrc-compat): '$cmd' is not supported." >&2; exit 1 ;;
esac