I made the changes you suggested, plus a few others. Still having some difficulty making Sunshine behave with OpenRC. Here are the script, and the terminal output:
#!/sbin/openrc-run
# An amateur attempt at an OpenRC script for Sunshine
# https://github.com/loki-47-6F-64/sunshine
# For a true tutorial on how to write decent OpenRC init scripts, goto:
# https://github.com/OpenRC/openrc/blob/master/service-script-guide.md
# The service is given a name, a description, and a specified binary location.
name="sunshined"
description="Sunshine Gamestream Server for Moonlight"
command="/usr/bin/sunshine"
# RC_SVCNAME is a variable that should contain the name of the service.
# If this does not work, can replace it with the word sunshine instead.
command_args="-p ${pidfile}"
pidfile="/var/run/${RC_SVCNAME}.pid"
# The previous two lines assume that sunshine is a 'a well-behaved daemon that backgrounds itself and writes its own PID file by default'.
command_background=true
# But this line is here because we know better - it needs to be sent to the background.
# If sunshine needs to have its user or group changed for it, the following line can be used.
command_user="tophatproductions115:input"
# Perhaps I should use the default user group instead (tophatproductions115) ?
depend() {
# Wait for the display manager, so we can actually have a graphical session to work with
need lightdm
}
# Before we begin, there is one last thing to attend to...
start_pre() {
einfo "Loading uinput module"
/usr/bin/modprobe uinput 2>&1
}
# The start-stop commands, for when it's time to roll.
start() {
ebegin "Initialising sunshined..."
# Be sure to set the X display - if you have more than one X display, set it to the non-local-session.
DISPLAY=:0
start-stop-daemon --start --exec /usr/bin/sunshine
eend $?
}
stop() {
ebegin "Terminating sunshined..."
start-stop-daemon --stop --exec /usr/bin/sunshine
eend $?
}
# In many cases, you shouldn't have to roll your own start, stop, and status functions.
# If you need yours to do something that the standard implementation does not do, feel free to write your own.
➜ ~ sudo rc-service sunshined start
sunshined | * Caching service dependencies ... [ ok ]
sunshined | * Loading uinput module
sunshined | * Initialising sunshined... ...
sunshined |[output_name] -- [0]
sunshined |[upnp] -- [enabled]
sunshined |[nv_coder] -- [auto]
sunshined |[resolutions] -- [[
sunshined | 352x240,
sunshined | 480x360,
sunshined | 858x480,
sunshined | 1280x720,
sunshined | 1920x1080,
sunshined | 2560x1080,
sunshined | 3440x1440,
sunshined | 1920x1200,
sunshined | 3860x2160,
sunshined | 3840x1600
sunshined |]]
sunshined |[min_log_level] -- [2]
sunshined |[origin_web_ui_allowed] -- [lan]
sunshined |[origin_pin_allowed] -- [pc]
sunshined |[hevc_mode] -- [0]
sunshined |[amd_rc] -- [auto]
sunshined |[nv_preset] -- [default]
sunshined |[nv_rc] -- [auto]
sunshined |[amd_quality] -- [default]
sunshined |[fps] -- [[10,30,60,90,120]]
sunshined |[2021:08:31:21:31:01]: Fatal: Could not open x11 display for keyboard
sunshined | * start-stop-daemon: failed to start `/usr/bin/sunshine' [ !! ]
sunshined | * ERROR: sunshined failed to start
I'll need to do some more research on this. Something is preventing the service from starting successfully. May have to just kick VMware's video adapter from the equation, so that the only one left standing is the nVIDIA GRID card...