mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
feat(runner): Container detection and handling, video bit-depth flags and script updates (#303)
## Description Works in apptainer now.. podman is still the goat since apptainer needs docker treatment and even more.. - Added container detection so podman can be used to it's fullest, the non-sane ones are handled separately.. - Added video bit-depth option, cuz AV1 and 10-bit encoding go well together. - Some other package updates to nestri-server. - General tidying up of scripts to make multi-container-engine handling less of a pain. - Updated old wireplumber lua script to new json format. Further changes: - Removed unused debug arg from nestri-server. - Moved configs to config file folder rather than keeping them in containerfile. - Improved audio configs, moved some into wireplumber to keep things tidy. - Bit better arg handling in nestri-server. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Optional 10‑bit video support and auto‑launch of an app after display setup. * **Changes** * Standardized runtime/user env to NESTRI_* with updated home/cache paths and explicit LANG; password generation now logged. * Improved container/GPU detection and startup logging; reduced blanket root usage during startup; SSH setup surfaced. * WirePlumber/PipeWire moved to JSON configs; low‑latency clock and loopback audio policies added; audio capture defaults to PipeWire. * **Chores** * GStreamer/libp2p dependency upgrades and Rust toolchain pinned; NVIDIA driver capability exposed. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: DatCaptainHorse <DatCaptainHorse@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
aba0bc3be1
commit
590fe5e196
@@ -1,8 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
log() {
|
||||
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
|
||||
}
|
||||
# Common helpers as requirement
|
||||
if [[ -f /etc/nestri/common.sh ]]; then
|
||||
source /etc/nestri/common.sh
|
||||
else
|
||||
echo "Error: Common script not found at /etc/nestri/common.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Parses resolution string
|
||||
parse_resolution() {
|
||||
@@ -23,20 +27,10 @@ parse_resolution() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Loads environment variables
|
||||
load_envs() {
|
||||
if [[ -f /etc/nestri/envs.sh ]]; then
|
||||
log "Sourcing environment variables from envs.sh..."
|
||||
source /etc/nestri/envs.sh
|
||||
else
|
||||
log "Error: envs.sh not found at /etc/nestri/envs.sh"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Configuration
|
||||
MAX_RETRIES=3
|
||||
RETRY_COUNT=0
|
||||
WAYLAND_READY_DELAY=3
|
||||
|
||||
# Kills process if running
|
||||
kill_if_running() {
|
||||
@@ -125,15 +119,15 @@ start_nestri_server() {
|
||||
WAYLAND_SOCKET="${XDG_RUNTIME_DIR}/wayland-1"
|
||||
for ((i=1; i<=15; i++)); do
|
||||
if [[ -e "$WAYLAND_SOCKET" ]]; then
|
||||
log "Wayland display 'wayland-1' ready."
|
||||
sleep 3
|
||||
log "Wayland display 'wayland-1' ready"
|
||||
sleep "${WAYLAND_READY_DELAY:-3}"
|
||||
start_compositor
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
log "Error: Wayland display 'wayland-1' not available."
|
||||
log "Error: Wayland display 'wayland-1' not available"
|
||||
|
||||
# Workaround for gstreamer being bit slow at times
|
||||
log "Clearing gstreamer cache.."
|
||||
@@ -156,8 +150,8 @@ start_compositor() {
|
||||
NESTRI_LAUNCH_COMPOSITOR="gamescope --backend wayland --force-grab-cursor -g -f --rt --mangoapp -W ${WIDTH} -H ${HEIGHT} -r ${FRAMERATE:-60}"
|
||||
fi
|
||||
|
||||
# Start Steam patcher only if Steam command is present
|
||||
if [[ -n "${NESTRI_LAUNCH_CMD}" ]] && [[ "$NESTRI_LAUNCH_CMD" == *"steam"* ]]; then
|
||||
# Start Steam patcher only if Steam command is present and if needed for container runtime
|
||||
if [[ -n "${NESTRI_LAUNCH_CMD}" ]] && [[ "$NESTRI_LAUNCH_CMD" == *"steam"* ]] && [[ "${container_runtime:-}" != "podman" ]]; then
|
||||
start_steam_namespaceless_patcher
|
||||
fi
|
||||
|
||||
@@ -200,17 +194,23 @@ start_compositor() {
|
||||
local OUTPUT_NAME
|
||||
OUTPUT_NAME=$(WAYLAND_DISPLAY=wayland-0 wlr-randr --json | jq -r '.[] | select(.enabled == true) | .name' | head -n 1)
|
||||
if [ -z "$OUTPUT_NAME" ]; then
|
||||
log "Warning: No enabled outputs detected. Skipping wlr-randr resolution patch."
|
||||
log "Warning: No enabled outputs detected. Skipping wlr-randr resolution patch"
|
||||
return
|
||||
fi
|
||||
WAYLAND_DISPLAY=wayland-0 wlr-randr --output "$OUTPUT_NAME" --custom-mode "$WIDTH"x"$HEIGHT"
|
||||
log "Patched resolution with wlr-randr."
|
||||
log "Patched resolution with wlr-randr"
|
||||
|
||||
if [[ -n "${NESTRI_LAUNCH_CMD}" ]]; then
|
||||
log "Starting application: $NESTRI_LAUNCH_CMD"
|
||||
WAYLAND_DISPLAY=wayland-0 /bin/bash -c "$NESTRI_LAUNCH_CMD" &
|
||||
APP_PID=$!
|
||||
fi
|
||||
fi
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
log "Warning: Compositor socket not found after 15 seconds ($COMPOSITOR_SOCKET)."
|
||||
log "Warning: Compositor socket not found after 15 seconds ($COMPOSITOR_SOCKET)"
|
||||
else
|
||||
# Launch standalone application if no compositor
|
||||
if [[ -n "${NESTRI_LAUNCH_CMD}" ]]; then
|
||||
@@ -218,7 +218,7 @@ start_compositor() {
|
||||
WAYLAND_DISPLAY=wayland-1 /bin/bash -c "$NESTRI_LAUNCH_CMD" &
|
||||
APP_PID=$!
|
||||
else
|
||||
log "No compositor or application configured."
|
||||
log "No compositor or application configured"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -228,7 +228,7 @@ increment_retry() {
|
||||
local component="$1"
|
||||
((RETRY_COUNT++))
|
||||
if [[ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]]; then
|
||||
log "Error: Max retries reached for $component."
|
||||
log "Error: Max retries reached for $component"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -259,22 +259,22 @@ main_loop() {
|
||||
sleep 1
|
||||
# Check nestri-server
|
||||
if [[ -n "${NESTRI_PID:-}" ]] && ! kill -0 "${NESTRI_PID}" 2>/dev/null; then
|
||||
log "nestri-server died."
|
||||
log "nestri-server died"
|
||||
increment_retry "nestri-server"
|
||||
restart_chain
|
||||
# Check compositor
|
||||
elif [[ -n "${COMPOSITOR_PID:-}" ]] && ! kill -0 "${COMPOSITOR_PID}" 2>/dev/null; then
|
||||
log "compositor died."
|
||||
log "compositor died"
|
||||
increment_retry "compositor"
|
||||
start_compositor
|
||||
# Check application
|
||||
elif [[ -n "${APP_PID:-}" ]] && ! kill -0 "${APP_PID}" 2>/dev/null; then
|
||||
log "application died."
|
||||
log "application died"
|
||||
increment_retry "application"
|
||||
start_compositor
|
||||
# Check patcher
|
||||
elif [[ -n "${PATCHER_PID:-}" ]] && ! kill -0 "${PATCHER_PID}" 2>/dev/null; then
|
||||
log "steam-patcher died."
|
||||
log "steam-patcher died"
|
||||
increment_retry "steam-patcher"
|
||||
start_steam_namespaceless_patcher
|
||||
fi
|
||||
@@ -282,10 +282,18 @@ main_loop() {
|
||||
}
|
||||
|
||||
main() {
|
||||
load_envs
|
||||
parse_resolution "${RESOLUTION:-1920x1080}" || exit 1
|
||||
get_container_info || {
|
||||
log "Warning: Failed to detect container information."
|
||||
}
|
||||
|
||||
# Ensure DBus session env exists
|
||||
if command -v dbus-launch >/dev/null 2>&1 && [[ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]]; then
|
||||
eval "$(dbus-launch)"
|
||||
fi
|
||||
|
||||
restart_chain
|
||||
main_loop
|
||||
}
|
||||
|
||||
main
|
||||
main
|
||||
|
||||
Reference in New Issue
Block a user