Files
docker-steam-headless/overlay/usr/bin/sunshine-run
Josh.5 97613b227f Run Sunshine as a service
Goodbye Flatpak Sunshine. Hello AppImage.
Until a deb package is available for Debian Bookworm, we can just run sunshine as an AppImage.
It is faster to startup and is a little less bloated.

The goal here is to run Sunshine as a service managed by supervisord so that it is kept running and is restarted automatically if stopped.
2023-08-29 18:02:03 +12:00

50 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
###
# File: sunshine-run
# Project: bin
# File Created: Tuesday, 23rd August 2023 3:28:52 pm
# Author: Josh.5 (jsunnex@gmail.com)
# -----
# Last Modified: Friday, 23rd August 2023 4:21:00 pm
# Modified By: Josh.5 (jsunnex@gmail.com)
###
set -e
exec >> >(tee -a /tmp/sunshine-exec-run.log) 2>&1
echo
echo "-------------------------------"
echo
date
echo
echo "-------------------------------"
echo
echo "**** Execute sunshine-run ****"
echo
# Trap SIGINT, SIGQUIT, SIGHUP, SIGTERM to forward signals to the child process
_term() {
if [ -n "${proc_pid}" ]; then
echo " - Forwarding signal $1 to process ${proc_pid}"
kill -s "${1}" "${proc_pid}"
fi
}
trap '_term INT' SIGINT
trap '_term QUIT' SIGQUIT
trap '_term HUP' SIGHUP
trap '_term TERM' SIGTERM
# Run child process
/usr/bin/dumb-init "${@}" &
proc_pid=$!
echo " - Recording sunshine-run PID '${proc_pid}' in /tmp/sunshine-exec-run.pid"
echo "${proc_pid}" > /tmp/sunshine-exec-run.pid
# Wait for child process to exit:
echo " - Waiting for PID '${proc_pid}' to exit"
wait "$proc_pid"
# Clean up PID file
rm -f /tmp/sunshine-exec-run.pid
echo "DONE"