2 Commits

Author SHA1 Message Date
Josh.5
dd5cfcd69e Add a plugins executor 2023-02-06 00:02:30 +00:00
Josh.5
651e9d2f25 [WIP] Add start of sunshine docker container 2023-02-05 20:55:32 +00:00
7 changed files with 176 additions and 1 deletions

View File

@@ -1,2 +1,4 @@
config
devops
docs/compose-files/default
docs/compose-files/sunshine

2
.gitignore vendored
View File

@@ -1 +1,3 @@
config
docs/compose-files/default
docs/compose-files/sunshine

View File

@@ -574,7 +574,7 @@ ENV \
ENABLE_VNC_AUDIO="true" \
NEKO_PASSWORD=neko \
NEKO_PASSWORD_ADMIN=admin \
ENABLE_SUNSHINE="false" \
ENABLED_PLUGINS="" \
ENABLE_EVDEV_INPUTS="false"
# Configure required ports

View File

@@ -0,0 +1,80 @@
---
# --memory='8g'
# --ulimit nofile=1024:524288
services:
steam-headless:
image: josh5/steam-headless:latest
restart: unless-stopped
runtime: ${DOCKER_RUNTIME}
## NOTE: Requires privileged access to host to be able to access the required devices
privileged: true
shm_size: ${SHM_SIZE}
ipc: host # Could also be set to 'shareable'
# NETWORK:
## NOTE: Steam headless always required the use of the host network
network_mode: host
hostname: ${HOSTNAME}
extra_hosts:
- "${HOSTNAME}:127.0.0.1"
# ENVIRONMENT:
## Read all config variables from the .env file
env_file: .env
# VOLUMES:
volumes:
# The location of your home directory.
# TODO: Make this '/opt/container-data/steam-headless/home/:/home/default/'
- ./default/:/home/default/:rw
# The location where all games should be installed.
- /mnt/Games/:/mnt/games/:rw
# Input devices used for mouse and joypad support inside the container.
- /dev/input/:/dev/input/:ro
# The Xorg socket. This will be shared with other containers so they can access the X server.
- /opt/container-data/steam-headless/.X11-unix/:/tmp/.X11-unix/:rw
# Pulse audio socket. This will be shared with other containers so they can access the audio sink.
- /opt/container-data/steam-headless/pulse/:/tmp/pulse/:rw
####################
# Sunshine is the heart of the streaming setup; it takes your desktop and
# encodes it for delivery over the network
sunshine:
depends_on:
- steam-headless
image: ghcr.io/games-on-whales/sunshine:edge
runtime: ${DOCKER_RUNTIME}
ports:
- 47984-47990:47984-47990/tcp
- 48010:48010
- 47998-48000:47998-48000/udp
privileged: true
volumes:
# The location of your homle directory.
# TODO: Make this '/opt/container-data/steam-headless/home/:/home/retro/'
- ./sunshine/:/home/retro/:rw
# The Xorg socket.
- /opt/container-data/steam-headless/.X11-unix/:/tmp/.X11-unix/:rw
# Pulse audio socket.
- /opt/container-data/steam-headless/pulse/:/tmp/pulse/:rw
# OPTIONAL: host dbus used by avahi in order to publish Sunshine for auto network discovery
- /run/dbus/:/run/dbus/:ro
ipc: host
# ENVIRONMENT:
## Read all config variables from the .env fie
env_file: .env
environment:
LOG_LEVEL: INFO
GOW_REQUIRED_DEVICES: /dev/uinput /dev/input/event* /dev/dri/*
# Username and password for the web-ui at https://xxx.xxx.xxx.xxx:47990
SUNSHINE_USER: admin
SUNSHINE_PASS: admin
XDG_RUNTIME_DIR: /tmp/.X11-unix/run
# Intel specific config
LIBVA_DRIVER_NAME: i965
LIBVA_DRIVERS_PATH: /usr/lib/x86_64-linux-gnu/dri/
# Configure the pulseaudio socket
PULSE_SERVER: unix:/tmp/pulse/pulse-socket

View File

@@ -0,0 +1,16 @@
echo "**** Configure Plugins ****"
if ([ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then
if [ "X${ENABLED_PLUGINS:-}" != "X" ]; then
echo "Enable Plugins"
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/plugins.ini
chmod +x /usr/bin/start-plugins.sh
else
echo "Disable Plugins"
fi
else
echo "Plugins not available when container is run in 'secondary' mode"
fi
echo "DONE"

View File

@@ -0,0 +1,16 @@
[program:plugins]
priority=50
autostart=false
autorestart=false
user=%(ENV_USER)s
directory=/home/%(ENV_USER)s
command=/usr/bin/start-plugins.sh
environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s"
stopsignal=INT
stdout_logfile=/home/%(ENV_USER)s/.cache/log/plugins.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=7
stderr_logfile=/home/%(ENV_USER)s/.cache/log/plugins.err.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=7

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env bash
###
# File: start-plugins.sh
# Project: bin
# File Created: Sunday, 5th February 2023 10:07:02 pm
# Author: Josh.5 (jsunnex@gmail.com)
# -----
# Last Modified: Sunday, 5th February 2023 11:55:11 pm
# Modified By: Josh.5 (jsunnex@gmail.com)
###
set -e
source /usr/bin/common-functions.sh
# CATCH TERM SIGNAL:
_term() {
kill -TERM "$plugins_pid" 2>/dev/null
}
trap _term SIGTERM SIGINT
echo "USER: $USER"
echo "HOME: $HOME"
echo "ENABLED_PLUGINS: $ENABLED_PLUGINS"
# CONFIGURE:
# Set the plugins project directory
plugins_dir="/home/${USER}/.local/share/steam-headless-plugins2"
# Clone plugins project
mkdir -p "/home/${USER}/.local/share"
if [[ ! -d "${plugins_dir}" ]]; then
git clone --depth=1 \
https://github.com/Steam-Headless/plugins.git \
"${plugins_dir}"
fi
# Pull latest project
pushd "${plugins_dir}" &> /dev/null || exit 1
git clean -fdx
git checkout . 2> /dev/null
git checkout master 2> /dev/null
git pull origin master 2> /dev/null
popd &> /dev/null || exit 1
# EXECUTE PROCESS:
# Wait for the X server to start
wait_for_docker
pushd "${plugins_dir}" &> /dev/null || exit 1
## # Pull latest Docker images
## ${plugins_dir}/plugins-run pull
## # Run docker images (not in background)
## ${plugins_dir}/plugins-run up &
sleep 300
plugins_pid=$!
popd &> /dev/null || exit 1
# WAIT FOR CHILD PROCESS:
wait "$plugins_pid"