LizardByte / Sunshine

Self-hosted game stream host for Moonlight.
http://app.lizardbyte.dev/Sunshine/
GNU General Public License v3.0
18.79k stars 910 forks source link

[Nightly] Systemd sunshine service not found in nightly and perhaps udev rules are not installed. #2038

Closed PVermeer closed 8 months ago

PVermeer commented 8 months ago

Is there an existing issue for this?

Is your issue described in the documentation?

Is your issue present in the nightly release?

Describe the Bug

After fresh install of latest nightly:

$ systemctl --user start sunshine
Unit sunshine.service could not be found.

Some debugging revealed that some rpm install paths are changed to /usr/lib64/ from /usr/lib/:

$ rpm -qvlp ./Downloads/sunshine-fedora-39-amd64.rpm 
lrwxrwxrwx    1 root     root                       56 Jul  4  2010 /usr/bin/sunshine -> sunshine-0.21.0.b94f8c0b5037d8b5cac8da51c363b263429a49cc
-rwxr-xr-x    1 root     root                 19300704 Jul  4  2010 /usr/bin/sunshine-0.21.0.b94f8c0b5037d8b5cac8da51c363b263429a49cc
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/lib/.build-id
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/lib/.build-id/ba
lrwxrwxrwx    1 root     root                       76 Jul  4  2010 /usr/lib/.build-id/ba/707557efc6e3e809f35b37dd1652d53428a3a3 -> ../../../../usr/bin/sunshine-0.21.0.b94f8c0b5037d8b5cac8da51c363b263429a49cc
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/lib64/systemd
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/lib64/systemd/user
-rw-r--r--    1 root     root                      344 Jul  4  2010 /usr/lib64/systemd/user/sunshine.service
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/lib64/udev
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/lib64/udev/rules.d
-rw-r--r--    1 root     root                       82 Jul  4  2010 /usr/lib64/udev/rules.d/85-sunshine.rules
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/applications
-rw-r--r--    1 root     root                      442 Jul  4  2010 /usr/share/applications/sunshine.desktop
-rw-r--r--    1 root     root                       90 Jul  4  2010 /usr/share/applications/sunshine_terminal.desktop
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/icons
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/icons/hicolor
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/icons/hicolor/scalable
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/icons/hicolor/scalable/apps
-rw-r--r--    1 root     root                     2138 Jul  4  2010 /usr/share/icons/hicolor/scalable/apps/sunshine.svg
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/icons/hicolor/scalable/status
-rw-r--r--    1 root     root                     4050 Jul  4  2010 /usr/share/icons/hicolor/scalable/status/sunshine-locked.svg
-rw-r--r--    1 root     root                     3903 Jul  4  2010 /usr/share/icons/hicolor/scalable/status/sunshine-pausing.svg
-rw-r--r--    1 root     root                     4116 Jul  4  2010 /usr/share/icons/hicolor/scalable/status/sunshine-playing.svg
-rw-r--r--    1 root     root                     2138 Jul  4  2010 /usr/share/icons/hicolor/scalable/status/sunshine-tray.svg
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/metainfo
-rw-r--r--    1 root     root                     1085 Jul  4  2010 /usr/share/metainfo/sunshine.appdata.xml
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/sunshine
-rw-r--r--    1 root     root                      552 Jul  4  2010 /usr/share/sunshine/apps.json
-rw-r--r--    1 root     root                      680 Jul  4  2010 /usr/share/sunshine/box.png
-rw-r--r--    1 root     root                     8737 Jul  4  2010 /usr/share/sunshine/desktop-alt.png
-rw-r--r--    1 root     root                     8231 Jul  4  2010 /usr/share/sunshine/desktop.png
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/sunshine/shaders
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/sunshine/shaders/opengl
-rw-r--r--    1 root     root                      828 Jul  4  2010 /usr/share/sunshine/shaders/opengl/ConvertUV.frag
-rw-r--r--    1 root     root                      620 Jul  4  2010 /usr/share/sunshine/shaders/opengl/ConvertUV.vert
-rw-r--r--    1 root     root                      399 Jul  4  2010 /usr/share/sunshine/shaders/opengl/ConvertY.frag
-rw-r--r--    1 root     root                      181 Jul  4  2010 /usr/share/sunshine/shaders/opengl/Scene.frag
-rw-r--r--    1 root     root                      347 Jul  4  2010 /usr/share/sunshine/shaders/opengl/Scene.vert
-rw-r--r--    1 root     root                    24833 Jul  4  2010 /usr/share/sunshine/steam.png
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/sunshine/web
-rw-r--r--    1 root     root                    17060 Jul  4  2010 /usr/share/sunshine/web/apps.html
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/sunshine/web/assets
-rw-r--r--    1 root     root                       72 Jul  4  2010 /usr/share/sunshine/web/assets/Navbar-48ec9d0d.css
-rw-r--r--    1 root     root                     1786 Jul  4  2010 /usr/share/sunshine/web/assets/Navbar-64f82ec1.js
-rw-r--r--    1 root     root                     1303 Jul  4  2010 /usr/share/sunshine/web/assets/ResourceCard-7110d947.js
-rw-r--r--    1 root     root                   331054 Jul  4  2010 /usr/share/sunshine/web/assets/_plugin-vue_export-helper-63d343c5.css
-rw-r--r--    1 root     root                   236078 Jul  4  2010 /usr/share/sunshine/web/assets/_plugin-vue_export-helper-83ac5eeb.js
-rw-r--r--    1 root     root                    85481 Jul  4  2010 /usr/share/sunshine/web/assets/apps-2ebdc1e4.js
-rw-r--r--    1 root     root                     4612 Jul  4  2010 /usr/share/sunshine/web/assets/config-4cfa105d.js
-rw-r--r--    1 root     root                   117372 Jul  4  2010 /usr/share/sunshine/web/assets/fa-brands-400-3a8924cd.woff2
-rw-r--r--    1 root     root                   207972 Jul  4  2010 /usr/share/sunshine/web/assets/fa-brands-400-5656d596.ttf
-rw-r--r--    1 root     root                    25452 Jul  4  2010 /usr/share/sunshine/web/assets/fa-regular-400-2bccecf0.woff2
-rw-r--r--    1 root     root                    68004 Jul  4  2010 /usr/share/sunshine/web/assets/fa-regular-400-5d02dc9b.ttf
-rw-r--r--    1 root     root                   156496 Jul  4  2010 /usr/share/sunshine/web/assets/fa-solid-900-9fc85f3a.woff2
-rw-r--r--    1 root     root                   419720 Jul  4  2010 /usr/share/sunshine/web/assets/fa-solid-900-fbbf06d7.ttf
-rw-r--r--    1 root     root                    10832 Jul  4  2010 /usr/share/sunshine/web/assets/fa-v4compatibility-09663a36.ttf
-rw-r--r--    1 root     root                     4792 Jul  4  2010 /usr/share/sunshine/web/assets/fa-v4compatibility-4d4a2d7f.woff2
-rw-r--r--    1 root     root                     1977 Jul  4  2010 /usr/share/sunshine/web/assets/index-d1be9fce.js
-rw-r--r--    1 root     root                      603 Jul  4  2010 /usr/share/sunshine/web/assets/password-47f1ebd0.js
-rw-r--r--    1 root     root                      812 Jul  4  2010 /usr/share/sunshine/web/assets/pin-eb28910b.js
-rw-r--r--    1 root     root                     1329 Jul  4  2010 /usr/share/sunshine/web/assets/troubleshooting-40280759.js
-rw-r--r--    1 root     root                      626 Jul  4  2010 /usr/share/sunshine/web/assets/welcome-7391d7ef.js
-rw-r--r--    1 root     root                    52359 Jul  4  2010 /usr/share/sunshine/web/config.html
drwxr-xr-x    2 root     root                        0 Jul  4  2010 /usr/share/sunshine/web/images
-rw-r--r--    1 root     root                      643 Jul  4  2010 /usr/share/sunshine/web/images/logo-sunshine-16.png
-rw-r--r--    1 root     root                     1607 Jul  4  2010 /usr/share/sunshine/web/images/logo-sunshine-45.png
-rw-r--r--    1 root     root                      650 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-locked-16.png
-rw-r--r--    1 root     root                     1980 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-locked-45.png
-rw-r--r--    1 root     root                   118386 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-locked.ico
-rw-r--r--    1 root     root                    12555 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-locked.png
-rw-r--r--    1 root     root                     4050 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-locked.svg
-rw-r--r--    1 root     root                      681 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-pausing-16.png
-rw-r--r--    1 root     root                     1868 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-pausing-45.png
-rw-r--r--    1 root     root                   108264 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-pausing.ico
-rw-r--r--    1 root     root                    10968 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-pausing.png
-rw-r--r--    1 root     root                     3903 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-pausing.svg
-rw-r--r--    1 root     root                      687 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-playing-16.png
-rw-r--r--    1 root     root                     2044 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-playing-45.png
-rw-r--r--    1 root     root                   120138 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-playing.ico
-rw-r--r--    1 root     root                    12100 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-playing.png
-rw-r--r--    1 root     root                     4116 Jul  4  2010 /usr/share/sunshine/web/images/sunshine-playing.svg
-rw-r--r--    1 root     root                   123128 Jul  4  2010 /usr/share/sunshine/web/images/sunshine.ico
-rw-r--r--    1 root     root                     3342 Jul  4  2010 /usr/share/sunshine/web/index.html
-rw-r--r--    1 root     root                     3202 Jul  4  2010 /usr/share/sunshine/web/password.html
-rw-r--r--    1 root     root                     1444 Jul  4  2010 /usr/share/sunshine/web/pin.html
-rw-r--r--    1 root     root                     4157 Jul  4  2010 /usr/share/sunshine/web/troubleshooting.html
-rw-r--r--    1 root     root                     2821 Jul  4  2010 /usr/share/sunshine/web/welcome.html

Scriptlet seems fine:

$ rpm -qp --scripts ./Downloads/sunshine-fedora-39-amd64.rpm 
postinstall scriptlet (using /bin/sh):

#!/bin/sh

# Ensure Sunshine can grab images from KMS
path_to_setcap=$(which setcap)
if [ -x "$path_to_setcap" ] ; then
  echo "$path_to_setcap cap_sys_admin+p /usr/bin/sunshine"
    $path_to_setcap cap_sys_admin+p $(readlink -f /usr/bin/sunshine)
fi

I dont know if this is intentional but at least the service is not detected by systemd.

Expected Behavior

To be able to enable and start the service and udev rules to be applied.

Additional Context

No response

Host Operating System

Linux

Operating System Version

Fedora 39 Gnome up to date

Architecture

64 bit

Sunshine commit or version

sunshine-0.21.0.b94f8c0b5037d8b5cac8da51c363b263429a49cc

Package

Linux - rpm

GPU Type

AMD

GPU Model

RX 6650XT

GPU Driver/Mesa Version

23.3.3

Capture Method (Linux Only)

KMS

Config

Not relevant

Apps

Not relevant

Relevant log output

Not relevant
PVermeer commented 8 months ago

Did some digging to understand cmake variable definitions because of: https://github.com/LizardByte/Sunshine/blob/6cdb7f7d032f075aac16eaae810dd1663923015a/cmake/packaging/linux.cmake#L10-L14

And found: https://gitlab.kitware.com/cmake/cmake/-/blob/v3.26.4/Modules/GNUInstallDirs.cmake?ref_type=tags#L221-231

  set(_LIBDIR_DEFAULT "lib")
  # Override this default 'lib' with 'lib64' iff:
  #  - we are on Linux system but NOT cross-compiling
  #  - we are NOT on debian
  #  - we are NOT building for conda
  #  - we are on a 64 bits system
  # reason is: amd64 ABI: https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
  # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if
  # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu"
  # and CMAKE_INSTALL_PREFIX is "/usr"
  # See http://wiki.debian.org/Multiarch

I did some research and this should work: systemd

# Find systemd service dirs
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
    pkg_check_modules(SYSTEMD "systemd")
endif()

if (SYSTEMD_FOUND)
    execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
        --variable=systemd_user_unit_dir systemd
        OUTPUT_VARIABLE SYSTEMD_USER_UNIT_INSTALL_DIR)

    string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_USER_UNIT_INSTALL_DIR
        "${SYSTEMD_USER_UNIT_INSTALL_DIR}")

        execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
        --variable=systemd_system_unit_dir systemd
        OUTPUT_VARIABLE SYSTEMD_SYSTEM_UNIT_INSTALL_DIR)

    string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SYSTEM_UNIT_INSTALL_DIR
        "${SYSTEMD_SYSTEM_UNIT_INSTALL_DIR}")

        mark_as_advanced(SYSTEMD_USER_UNIT_INSTALL_DIR SYSTEMD_SYSTEM_UNIT_INSTALL_DIR)

endif ()

udev

# Find udev rules dir
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
    pkg_check_modules(UDEV "udev")
endif()

if (UDEV_FOUND)
    execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
        --variable=udevdir udev
        OUTPUT_VARIABLE UDEV_RULE_INSTALL_DIR)

    string(REGEX REPLACE "[ \t\n]+" "" UDEV_RULE_INSTALL_DIR
        "${UDEV_RULE_INSTALL_DIR}")

    set(UDEV_RULE_INSTALL_DIR "${UDEV_RULE_INSTALL_DIR}/rules.d")

    mark_as_advanced(UDEV_RULE_INSTALL_DIR)

endif ()

I could make a PR to test this out.

ReenigneArcher commented 8 months ago

I could make a PR to test this out.

PR would be welcomed

e-dong commented 8 months ago

Had a short convo with @ReenigneArcher. We may want to consider adding support to detect the init system of the user's system. Other linux distros use alternative init systems like runit, dinit, openrc, s6, etc.

PVermeer commented 8 months ago

That is a good point.

I have no knowledge about other init systems but for now we could easily check if systemd is used with SYSTEMD_FOUND and only run https://github.com/LizardByte/Sunshine/blob/78ed91af5cf56bd0e0195c66048064876e285761/cmake/packaging/linux.cmake#L16-L17 if its found.

Same goes for udev.

e-dong commented 8 months ago

I'm using runit, so I could help with that.

We would need specific files for different init system.

E.g. The runit service for udevd is a simple sh script.

[eric@m3tis ~]$ cat /etc/runit/sv/udevd/run
#!/bin/sh
udevadm control --exit
exec udevd
PVermeer commented 8 months ago

I thought about it a little more and it makes no sense in de context of this fix. The fix was only meant to fix some paths when building the deb and rpm files in the docker containers. Can you explain a little more what you want to accomplish?

Some more questions that I have are:

I think for other init systems we could write different 'FindX' files, their respective install files and probable some new docker containers if they need to be tested / released. But does LizardByte want to maintain all of this?

Other option, that i could think of, is to add cmake options (variables) for other init systems.

But I really have no idea of what needs to be changed.

ReenigneArcher commented 8 months ago

@PVermeer essentially, the build now fails if systemd is not found. I think your suggestion here is a decent one to at least allow Sunshine to build. https://github.com/LizardByte/Sunshine/issues/2038#issuecomment-1937096448

PVermeer commented 8 months ago

Yeah @ReenigneArcher,

Just write an 'if' statement around the systemd lines and it should build. I wouldn't advise in production since it would not throw en error.

if (SYSTEMD_FOUND)
    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service"
            DESTINATION "${SYSTEMD_USER_UNIT_INSTALL_DIR}")
endif ()

Always happy to help :)