Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yukino Song
2024-10-09 02:24:15 +08:00
9 changed files with 385 additions and 254 deletions

View File

@@ -26,8 +26,6 @@ Sunshine images are available with the following tag suffixes, based on their re
- `archlinux`
- `debian-bookworm`
- `fedora-39`
- `fedora-40`
- `ubuntu-22.04`
- `ubuntu-24.04`
@@ -157,8 +155,6 @@ The architectures supported by these images are shown in the table below.
|-----------------|--------------|---------------|
| archlinux | ✅ | ❌ |
| debian-bookworm | ✅ | ✅ |
| fedora-39 | ✅ | ❌ |
| fedora-40 | ✅ | ❌ |
| ubuntu-22.04 | ✅ | ✅ |
| ubuntu-24.04 | ✅ | ✅ |

View File

@@ -1,104 +0,0 @@
# syntax=docker/dockerfile:1
# artifacts: true
# platforms: linux/amd64
# platforms_pr: linux/amd64
# no-cache-filters: sunshine-base,artifacts,sunshine
ARG BASE=fedora
ARG TAG=39
FROM ${BASE}:${TAG} AS sunshine-base
FROM sunshine-base AS sunshine-build
ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
# note: BUILD_VERSION may be blank
ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# copy repository
WORKDIR /build/sunshine/
COPY --link .. .
# cmake and cpack
RUN <<_BUILD
#!/bin/bash
set -e
chmod +x ./scripts/linux_build.sh
./scripts/linux_build.sh \
--publisher-name='LizardByte' \
--publisher-website='https://app.lizardbyte.dev' \
--publisher-issue-url='https://app.lizardbyte.dev/support' \
--sudo-off
dnf clean all
rm -rf /var/cache/yum
_BUILD
# run tests
WORKDIR /build/sunshine/build/tests
# hadolint ignore=SC1091
RUN <<_TEST
#!/bin/bash
set -e
export DISPLAY=:1
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
./test_sunshine --gtest_color=yes
_TEST
FROM scratch AS artifacts
ARG BASE
ARG TAG
ARG TARGETARCH
COPY --link --from=sunshine-build /build/sunshine/build/cpack_artifacts/Sunshine.rpm /sunshine-${BASE}-${TAG}-${TARGETARCH}.rpm
FROM sunshine-base AS sunshine
# copy deb from builder
COPY --link --from=artifacts /sunshine*.rpm /sunshine.rpm
# install sunshine
RUN <<_INSTALL_SUNSHINE
#!/bin/bash
set -e
dnf -y update
dnf -y install /sunshine.rpm
dnf clean all
rm -rf /var/cache/yum
_INSTALL_SUNSHINE
# network setup
EXPOSE 47984-47990/tcp
EXPOSE 48010
EXPOSE 47998-48000/udp
# setup user
ARG PGID=1000
ENV PGID=${PGID}
ARG PUID=1000
ENV PUID=${PUID}
ENV TZ="UTC"
ARG UNAME=lizard
ENV UNAME=${UNAME}
ENV HOME=/home/$UNAME
# setup user
RUN <<_SETUP_USER
#!/bin/bash
set -e
groupadd -f -g "${PGID}" "${UNAME}"
useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}"
mkdir -p ${HOME}/.config/sunshine
ln -s ${HOME}/.config/sunshine /config
chown -R ${UNAME} ${HOME}
_SETUP_USER
USER ${UNAME}
WORKDIR ${HOME}
# entrypoint
ENTRYPOINT ["/usr/bin/sunshine"]

View File

@@ -1,104 +0,0 @@
# syntax=docker/dockerfile:1
# artifacts: true
# platforms: linux/amd64
# platforms_pr: linux/amd64
# no-cache-filters: sunshine-base,artifacts,sunshine
ARG BASE=fedora
ARG TAG=40
FROM ${BASE}:${TAG} AS sunshine-base
FROM sunshine-base AS sunshine-build
ARG BRANCH
ARG BUILD_VERSION
ARG COMMIT
# note: BUILD_VERSION may be blank
ENV BRANCH=${BRANCH}
ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# copy repository
WORKDIR /build/sunshine/
COPY --link .. .
# cmake and cpack
RUN <<_BUILD
#!/bin/bash
set -e
chmod +x ./scripts/linux_build.sh
./scripts/linux_build.sh \
--publisher-name='LizardByte' \
--publisher-website='https://app.lizardbyte.dev' \
--publisher-issue-url='https://app.lizardbyte.dev/support' \
--sudo-off
dnf clean all
rm -rf /var/cache/yum
_BUILD
# run tests
WORKDIR /build/sunshine/build/tests
# hadolint ignore=SC1091
RUN <<_TEST
#!/bin/bash
set -e
export DISPLAY=:1
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
./test_sunshine --gtest_color=yes
_TEST
FROM scratch AS artifacts
ARG BASE
ARG TAG
ARG TARGETARCH
COPY --link --from=sunshine-build /build/sunshine/build/cpack_artifacts/Sunshine.rpm /sunshine-${BASE}-${TAG}-${TARGETARCH}.rpm
FROM sunshine-base AS sunshine
# copy deb from builder
COPY --link --from=artifacts /sunshine*.rpm /sunshine.rpm
# install sunshine
RUN <<_INSTALL_SUNSHINE
#!/bin/bash
set -e
dnf -y update
dnf -y install /sunshine.rpm
dnf clean all
rm -rf /var/cache/yum
_INSTALL_SUNSHINE
# network setup
EXPOSE 47984-47990/tcp
EXPOSE 48010
EXPOSE 47998-48000/udp
# setup user
ARG PGID=1000
ENV PGID=${PGID}
ARG PUID=1000
ENV PUID=${PUID}
ENV TZ="UTC"
ARG UNAME=lizard
ENV UNAME=${UNAME}
ENV HOME=/home/$UNAME
# setup user
RUN <<_SETUP_USER
#!/bin/bash
set -e
groupadd -f -g "${PGID}" "${UNAME}"
useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}"
mkdir -p ${HOME}/.config/sunshine
ln -s ${HOME}/.config/sunshine /config
chown -R ${UNAME} ${HOME}
_SETUP_USER
USER ${UNAME}
WORKDIR ${HOME}
# entrypoint
ENTRYPOINT ["/usr/bin/sunshine"]

View File

@@ -54,28 +54,21 @@ CUDA is used for NVFBC capture.
</tr>
<tr>
<td rowspan="1">12.0.0</td>
<td rowspan="3">525.60.13</td>
<td rowspan="2">525.60.13</td>
<td rowspan="4">50;52;60;61;62;70;72;75;80;86;87;89;90</td>
<td>sunshine-debian-bookworm-{arch}.deb</td>
</tr>
<tr>
<td rowspan="1">12.4.0</td>
<td>sunshine-fedora-39-{arch}.rpm</td>
</tr>
<tr>
<td rowspan="1">12.5.1</td>
<td>sunshine.pkg.tar.zst</td>
</tr>
<tr>
<td rowspan="1">12.6.2</td>
<td rowspan="1">560.35.03</td>
<td rowspan="2">12.6.2</td>
<td rowspan="2">560.35.03</td>
<td>sunshine_{arch}.flatpak</td>
</tr>
<tr>
<td>n/a</td>
<td>n/a</td>
<td>n/a</td>
<td>sunshine-fedora-40-{arch}.rpm</td>
<td>Sunshine (copr)</td>
</tr>
</table>
@@ -165,26 +158,27 @@ sudo apt remove sunshine
```
#### Fedora
@tip{The package name is case-sensitive.}
##### Install
1. Add `rpmfusion` repositories.
1. Enable copr repository.
```bash
sudo dnf install \
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
```
2. Download `sunshine-{distro}-{distro-version}-{arch}.rpm` and run the following command.
```bash
sudo dnf install ./sunshine-{distro}-{distro-version}-{arch}.rpm
sudo dnf copr enable lizardbyte/stable
```
@note{The `{distro-version}` is the version of the distro we built the package on. The `{arch}` is the
architecture of your operating system.}
or
```bash
sudo dnf copr enable lizardbyte/beta
```
@tip{You can double-click the rpm file to see details about the package and begin installation.}
2. Install the package.
```bash
sudo dnf install Sunshine
```
##### Uninstall
```bash
sudo dnf remove sunshine
sudo dnf remove Sunshine
```
#### Flatpak

View File

@@ -8,8 +8,8 @@
"serve": "serve ./tests/fixtures/http --no-port-switching"
},
"dependencies": {
"@lizardbyte/shared-web": "2024.901.195233",
"vue": "3.5.3",
"@lizardbyte/shared-web": "2024.921.191855",
"vue": "3.5.11",
"vue-i18n": "9.14.0"
},
"devDependencies": {

View File

@@ -0,0 +1,62 @@
#! /bin/sh -x
# This file is not used directly in this repository. It should be uploaded to Copr whenever the file changes.
# Replicate to each package in "pulls", "beta", and "stable" Copr repositories
set -e
resultdir="${COPR_RESULTDIR}"
git clone "https://github.com/${COPR_OWNER}/${COPR_PACKAGE}.git" --depth 1
cd "${COPR_PACKAGE}"
# optional part; drop if building against 'master' is enough
if test -z "$REVISION"; then
# the hook_payload file contains webhook JSON payload (copr creates it for
# us); it is created only if the build is triggered by Custom webhook.
if test -f "$resultdir"/hook_payload; then
git clone https://github.com/praiskup/copr-ci-tooling \
"$resultdir/cct" --depth 1
export PATH="$resultdir/cct:$PATH"
echo "---"
cat "$resultdir"/hook_payload
echo "---"
# use jq to get the pr_id from the hook_payload
PR=$(jq -r '.pr_id' "$resultdir"/hook_payload)
if [ -z "$PR" ]; then
BRANCH="master"
else
BRANCH="pr/${PR}"
fi
copr-travis-checkout "$resultdir"/hook_payload
fi
else
git checkout "$REVISION"
fi
# initialize the submodules
git submodule update --init --recursive
# get the tag of this commit IF it has one
TAG=$(git tag --points-at HEAD | head -n1)
if [ -z "$TAG" ]; then
TAG="0.0.$PR"
fi
TAG=$(echo "$TAG" | sed 's/^v//') # remove v prefix from the tag
echo "TAG=$TAG"
# get the commit
COMMIT=$(git rev-parse HEAD)
echo "COMMIT=$COMMIT"
# move spec file to the correct location
mv packaging/linux/fedora/*.spec "${resultdir}"
# use sed to replace these values in the spec file
sed -i "s|%global build_version 0|%global build_version ${TAG}|" "${resultdir}"/*.spec
sed -i "s|%global branch 0|%global branch ${BRANCH}|" "${resultdir}"/*.spec
sed -i "s|%global commit 0|%global commit ${COMMIT}|" "${resultdir}"/*.spec
# create a tarball of the source code
tar -czf "${resultdir}/tarball.tar.gz" .

View File

@@ -0,0 +1,261 @@
%global build_timestamp %(date +"%Y%m%d")
# use sed to replace these values
%global build_version 0
%global branch 0
%global commit 0
%undefine _hardened_build
Name: Sunshine
Version: %{build_version}
Summary: Self-hosted game stream host for Moonlight.
Release: 1%{?dist}
License: GPLv3-only
URL: https://github.com/LizardByte/Sunshine
Source0: tarball.tar.gz
# BuildRequires: boost-devel >= 1.86.0
BuildRequires: cmake >= 3.25.0
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: libayatana-appindicator3-devel
BuildRequires: libcap-devel
BuildRequires: libcurl-devel
BuildRequires: libdrm-devel
BuildRequires: libevdev-devel
BuildRequires: libgudev
BuildRequires: libnotify-devel
BuildRequires: libva-devel
BuildRequires: libvdpau-devel
BuildRequires: libX11-devel
BuildRequires: libxcb-devel
BuildRequires: libXcursor-devel
BuildRequires: libXfixes-devel
BuildRequires: libXi-devel
BuildRequires: libXinerama-devel
BuildRequires: libXrandr-devel
BuildRequires: libXtst-devel
BuildRequires: git
BuildRequires: mesa-libGL-devel
BuildRequires: miniupnpc-devel
BuildRequires: npm
BuildRequires: numactl-devel
BuildRequires: openssl-devel
BuildRequires: opus-devel
BuildRequires: pulseaudio-libs-devel
BuildRequires: rpm-build
BuildRequires: systemd-udev
BuildRequires: systemd-rpm-macros
%{?sysusers_requires_compat}
BuildRequires: wget
BuildRequires: which
# for unit tests
BuildRequires: xorg-x11-server-Xvfb
# Conditional BuildRequires for cuda-gcc based on Fedora version
%if 0%{?fedora} >= 40
# this package conflicts with gcc on f39
BuildRequires: cuda-gcc-c++
%endif
Requires: libcap >= 2.22
Requires: libcurl >= 7.0
Requires: libdrm > 2.4.97
Requires: libevdev >= 1.5.6
Requires: libopusenc >= 0.2.1
Requires: libva >= 2.14.0
Requires: libvdpau >= 1.5
Requires: libwayland-client >= 1.20.0
Requires: libX11 >= 1.7.3.1
Requires: miniupnpc >= 2.2.4
Requires: numactl-libs >= 2.0.14
Requires: openssl >= 3.0.2
Requires: pulseaudio-libs >= 10.0
Requires: libayatana-appindicator3 >= 0.5.3
%description
Self-hosted game stream host for Moonlight.
%prep
# extract tarball to current directory
mkdir -p %{_builddir}/Sunshine
tar -xzf %{SOURCE0} -C %{_builddir}/Sunshine
# list directory
ls -a %{_builddir}/Sunshine
# patches
%autopatch -p1
%build
# Detect the architecture and Fedora version
architecture=$(uname -m)
fedora_version=%{fedora}
cuda_supported_architectures=("x86_64" "aarch64")
# set cuda_version based on Fedora version
# these are the same right now, but leave this structure to make it easier to set different versions
if [ "$fedora_version" == 39 ]; then
cuda_version="12.6.2"
cuda_build="560.35.03"
else
cuda_version="12.6.2"
cuda_build="560.35.03"
fi
# prepare CMAKE args
cmake_args=(
"-B=%{_builddir}/Sunshine/build"
"-G=Unix Makefiles"
"-S=."
"-DBUILD_DOCS=OFF"
"-DBUILD_WERROR=ON"
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_PREFIX=%{_prefix}"
"-DSUNSHINE_ASSETS_DIR=%{_datadir}/sunshine"
"-DSUNSHINE_EXECUTABLE_PATH=%{_bindir}/sunshine"
"-DSUNSHINE_ENABLE_WAYLAND=ON"
"-DSUNSHINE_ENABLE_X11=ON"
"-DSUNSHINE_ENABLE_DRM=ON"
"-DSUNSHINE_PUBLISHER_NAME=LizardByte"
"-DSUNSHINE_PUBLISHER_WEBSITE=https://app.lizardbyte.dev"
"-DSUNSHINE_PUBLISHER_ISSUE_URL=https://app.lizardbyte.dev/support"
)
function install_cuda() {
# check if we need to install cuda
if [ -f "%{_builddir}/cuda/bin/nvcc" ]; then
echo "cuda already installed"
return
fi
if [ "$fedora_version" -ge 40 ]; then
# update environment variables for CUDA, necessary when using cuda-gcc-c++
export NVCC_PREPEND_FLAGS='-ccbin /usr/bin/cuda'
export PATH=/usr/bin/cuda:"%{_builddir}/cuda/bin:${PATH}"
export LD_LIBRARY_PATH="%{_builddir}/cuda/lib64:${LD_LIBRARY_PATH}"
fi
local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/"
local cuda_suffix=""
if [ "$architecture" == "aarch64" ]; then
local cuda_suffix="_sbsa"
fi
local url="${cuda_prefix}${cuda_version}/local_installers/cuda_${cuda_version}_${cuda_build}_linux${cuda_suffix}.run"
echo "cuda url: ${url}"
wget \
"$url" \
--progress=bar:force:noscroll \
--retry-connrefused \
--tries=3 \
-q -O "%{_builddir}/cuda.run"
chmod a+x "%{_builddir}/cuda.run"
"%{_builddir}/cuda.run" \
--no-drm \
--no-man-page \
--no-opengl-libs \
--override \
--silent \
--toolkit \
--toolkitpath="%{_builddir}/cuda"
rm "%{_builddir}/cuda.run"
}
# we need to clear these flags to avoid linkage errors with cuda-gcc-c++
export CFLAGS=""
export CXXFLAGS=""
export FFLAGS=""
export FCFLAGS=""
export LDFLAGS=""
if [ -n "$cuda_version" ] && [[ " ${cuda_supported_architectures[@]} " =~ " ${architecture} " ]]; then
install_cuda
cmake_args+=("-DSUNSHINE_ENABLE_CUDA=ON")
cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=%{_builddir}/cuda/bin/nvcc")
fi
# setup the version
export BRANCH=%{branch}
export BUILD_VERSION=v%{build_version}
export COMMIT=%{commit}
# cmake
cd %{_builddir}/Sunshine
echo "cmake args:"
echo "${cmake_args[@]}"
cmake "${cmake_args[@]}"
make -j$(nproc) -C "%{_builddir}/Sunshine/build"
%check
# run tests
cd %{_builddir}/Sunshine/build
xvfb-run ./tests/test_sunshine
%install
cd %{_builddir}/Sunshine/build
%make_install
# Add modules-load configuration
# load the uhid module in initramfs even if it doesn't detect the module as being used during dracut
# which must be run every time a new kernel is installed
install -D -m 0644 /dev/stdin %{buildroot}/usr/lib/modules-load.d/uhid.conf <<EOF
uhid
EOF
%post
# Note: this is copied from the postinst script
# Check if we're in an rpm-ostree environment
if [ ! -x "$(command -v rpm-ostree)" ]; then
echo "Not in an rpm-ostree environment, proceeding with post install steps."
# Trigger udev rule reload for /dev/uinput and /dev/uhid
path_to_udevadm=$(which udevadm)
if [ -x "$path_to_udevadm" ]; then
echo "Reloading udev rules."
$path_to_udevadm control --reload-rules
$path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput
$path_to_udevadm trigger --property-match=DEVNAME=/dev/uhid
echo "Udev rules reloaded successfully."
else
echo "error: udevadm not found or not executable."
fi
else
echo "rpm-ostree environment detected, skipping post install steps. Restart to apply the changes."
fi
%preun
# Remove modules-load configuration
rm -f /usr/lib/modules-load.d/uhid.conf
%files
# Executables
%caps(cap_sys_admin+p) %{_bindir}/sunshine
%caps(cap_sys_admin+p) %{_bindir}/sunshine-*
# Systemd unit file for user services
%{_userunitdir}/sunshine.service
# Udev rules
%{_udevrulesdir}/*-sunshine.rules
# Modules-load configuration
%{_modulesloaddir}/uhid.conf
# Desktop entries
%{_datadir}/applications/sunshine*.desktop
# Icons
%{_datadir}/icons/hicolor/scalable/apps/sunshine.svg
%{_datadir}/icons/hicolor/scalable/status/sunshine*.svg
# Metainfo
%{_datadir}/metainfo/sunshine.appdata.xml
# Assets
%{_datadir}/sunshine/**
%changelog

View File

@@ -513,6 +513,7 @@ namespace video {
{ "delay"s, 0 },
{ "forced-idr"s, 1 },
{ "zerolatency"s, 1 },
{ "surfaces"s, 1 },
{ "preset"s, &config::video.nv_legacy.preset },
{ "tune"s, NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY },
{ "rc"s, NV_ENC_PARAMS_RC_CBR },
@@ -533,6 +534,7 @@ namespace video {
{ "delay"s, 0 },
{ "forced-idr"s, 1 },
{ "zerolatency"s, 1 },
{ "surfaces"s, 1 },
{ "preset"s, &config::video.nv_legacy.preset },
{ "tune"s, NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY },
{ "rc"s, NV_ENC_PARAMS_RC_CBR },
@@ -558,6 +560,7 @@ namespace video {
{ "delay"s, 0 },
{ "forced-idr"s, 1 },
{ "zerolatency"s, 1 },
{ "surfaces"s, 1 },
{ "preset"s, &config::video.nv_legacy.preset },
{ "tune"s, NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY },
{ "rc"s, NV_ENC_PARAMS_RC_CBR },
@@ -698,6 +701,9 @@ namespace video {
// Common options
{
{ "filler_data"s, false },
{ "forced_idr"s, 1 },
{ "latency"s, "lowest_latency"s },
{ "skip_frame"s, 0 },
{ "log_to_dbg"s, []() { return config::sunshine.min_log_level < 2 ? 1 : 0; } },
{ "preencode"s, &config::video.amd.amd_preanalysis },
{ "quality"s, &config::video.amd.amd_quality_av1 },
@@ -717,12 +723,13 @@ namespace video {
// Common options
{
{ "filler_data"s, false },
{ "forced_idr"s, 1 },
{ "latency"s, 1 },
{ "skip_frame"s, 0 },
{ "log_to_dbg"s, []() { return config::sunshine.min_log_level < 2 ? 1 : 0; } },
{ "gops_per_idr"s, 1 },
{ "header_insertion_mode"s, "idr"s },
{ "preencode"s, &config::video.amd.amd_preanalysis },
{ "qmax"s, 51 },
{ "qmin"s, 0 },
{ "quality"s, &config::video.amd.amd_quality_hevc },
{ "rc"s, &config::video.amd.amd_rc_hevc },
{ "usage"s, &config::video.amd.amd_usage_hevc },
@@ -741,10 +748,11 @@ namespace video {
// Common options
{
{ "filler_data"s, false },
{ "forced_idr"s, 1 },
{ "latency"s, 1 },
{ "frame_skipping"s, 0 },
{ "log_to_dbg"s, []() { return config::sunshine.min_log_level < 2 ? 1 : 0; } },
{ "preencode"s, &config::video.amd.amd_preanalysis },
{ "qmax"s, 51 },
{ "qmin"s, 0 },
{ "quality"s, &config::video.amd.amd_quality_h264 },
{ "rc"s, &config::video.amd.amd_rc_h264 },
{ "usage"s, &config::video.amd.amd_usage_h264 },
@@ -923,6 +931,7 @@ namespace video {
{ "require_sw"s, &config::video.vt.vt_require_sw },
{ "realtime"s, &config::video.vt.vt_realtime },
{ "prio_speed"s, 1 },
{ "max_ref_frames"s, 1 },
},
{}, // SDR-specific options
{}, // HDR-specific options
@@ -939,6 +948,7 @@ namespace video {
{ "require_sw"s, &config::video.vt.vt_require_sw },
{ "realtime"s, &config::video.vt.vt_realtime },
{ "prio_speed"s, 1 },
{ "max_ref_frames"s, 1 },
},
{}, // SDR-specific options
{}, // HDR-specific options
@@ -955,6 +965,7 @@ namespace video {
{ "require_sw"s, &config::video.vt.vt_require_sw },
{ "realtime"s, &config::video.vt.vt_realtime },
{ "prio_speed"s, 1 },
{ "max_ref_frames"s, 1 },
},
{}, // SDR-specific options
{}, // HDR-specific options

View File

@@ -1,17 +1,32 @@
#!/bin/sh
# Ensure Sunshine can grab images from KMS
path_to_setcap=$(which setcap)
path_to_sunshine=$(readlink -f $(which sunshine))
if [ -x "$path_to_setcap" ] ; then
echo "$path_to_setcap cap_sys_admin+p $path_to_sunshine"
$path_to_setcap cap_sys_admin+p $path_to_sunshine
fi
# Check if we're in an rpm-ostree environment
if [ ! -x "$(command -v rpm-ostree)" ]; then
echo "Not in an rpm-ostree environment, proceeding with post install steps."
# Trigger udev rule reload for /dev/uinput and /dev/uhid
path_to_udevadm=$(which udevadm)
if [ -x "$path_to_udevadm" ] ; then
$path_to_udevadm control --reload-rules
$path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput
$path_to_udevadm trigger --property-match=DEVNAME=/dev/uhid
# Ensure Sunshine can grab images from KMS
path_to_setcap=$(which setcap)
path_to_sunshine=$(readlink -f "$(which sunshine)")
if [ -x "$path_to_setcap" ] ; then
echo "Setting CAP_SYS_ADMIN capability on Sunshine binary."
echo "$path_to_setcap cap_sys_admin+p $path_to_sunshine"
$path_to_setcap cap_sys_admin+p $path_to_sunshine
echo "CAP_SYS_ADMIN capability set on Sunshine binary."
else
echo "error: setcap not found or not executable."
fi
# Trigger udev rule reload for /dev/uinput and /dev/uhid
path_to_udevadm=$(which udevadm)
if [ -x "$path_to_udevadm" ] ; then
echo "Reloading udev rules."
$path_to_udevadm control --reload-rules
$path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput
$path_to_udevadm trigger --property-match=DEVNAME=/dev/uhid
echo "Udev rules reloaded successfully."
else
echo "error: udevadm not found or not executable."
fi
else
echo "rpm-ostree environment detected, skipping post install steps. Restart to apply the changes."
fi