Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
PVermeer opened this issue Jan 18, 2024 · 8 comments · Fixed by #2046
Closed
3 tasks done
Labels
help wanted Extra attention is needed

Comments

@PVermeer
Copy link
Contributor

PVermeer commented Jan 18, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Is your issue described in the documentation?

  • I have read the documentation

Is your issue present in the nightly release?

  • This issue is 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
@ReenigneArcher ReenigneArcher added the help wanted Extra attention is needed label Jan 18, 2024
@PVermeer
Copy link
Contributor Author

PVermeer commented Jan 19, 2024

Did some digging to understand cmake variable definitions because of:

else()
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/85-sunshine.rules"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/udev/rules.d")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/user")

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
Copy link
Member

I could make a PR to test this out.

PR would be welcomed

@e-dong
Copy link
Contributor

e-dong commented Feb 10, 2024

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
Copy link
Contributor Author

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

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

Same goes for udev.

@e-dong
Copy link
Contributor

e-dong commented Feb 10, 2024

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
Copy link
Contributor Author

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:

  • Do you just want to build system to support more platforms and / or make different packages?
  • Do the current udev and/or unit files work with other init systems?

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
Copy link
Member

@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. #2038 (comment)

@PVermeer
Copy link
Contributor Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants