Skip to content

Instantly share code, notes, and snippets.

@mattisz
Forked from Nexarian/xrdp-intel-setup.sh
Last active July 23, 2024 19:30
Show Gist options
  • Save mattisz/269c243b9ec9c3e9a501e13d0dfd3672 to your computer and use it in GitHub Desktop.
Save mattisz/269c243b9ec9c3e9a501e13d0dfd3672 to your computer and use it in GitHub Desktop.
Setup for Intel acceleration and XRDP
#!/usr/bin/env bash
set -e
sudo -v
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
sudo usermod $USER -a -G video
sudo usermod $USER -a -G tty
sudo usermod $USER -a -G render
sudo usermod $USER -a -G audio
# XRDP Build Pre-reqs Part 1
sudo apt-get install -y git autoconf libtool pkg-config gcc g++ make libssl-dev libpam0g-dev \
libjpeg-dev libx11-dev libxfixes-dev libxrandr-dev flex bison libxml2-dev intltool xsltproc \
xutils-dev python3-libxml2 g++ xutils libfuse-dev libmp3lame-dev nasm libpixman-1-dev \
xserver-xorg-dev libjson-c-dev libsndfile1-dev libspeex-dev libspeexdsp-dev libpulse-dev \
libpulse0 autopoint \*turbojpeg\* libfdk-aac-dev libopus-dev libgbm-dev libx264\* \
libx264-dev build-essential dpkg-dev #xfce4 firefox-esr #optional
#XRDP Build Pre-reqs Part 2 (For some reason apt needs this to be separate)
sudo apt-get install -y libepoxy-dev
BUILD_DIR=$(mktemp -d)
echo "Building Intel YAMI and Media Driver"
sudo mkdir -p /usr/local/lib/x86_64-linux-gnu
git clone https://github.com/Nexarian/builders.git --branch update-to-media-driver "$BUILD_DIR/builders"
cd "$BUILD_DIR/builders/yami/omatic"
sed -i 's/cmake/cmake libx11-xcb-dev libxcb-dri3-dev/' buildyami.sh
sed -i 's|INSTALL_PATH=/opt/yami|INSTALL_PATH=/usr/local|' buildyami.sh
sed -i 's|LIBRARY_INSTALLATION_DIR=.*|LIBRARY_INSTALLATION_DIR=\$INSTALL_PATH/lib/x86_64-linux-gnu|' buildyami.sh
sed -i 's/2\.4\.114/2\.4\.116/' buildyami.sh
sed -i 's/2\.16\.0/2\.19\.0/' buildyami.sh
sed -i 's/2\.15\.0/2\.19\.0/' buildyami.sh
sed -i 's/22\.6\.2/23\.2\.4/' buildyami.sh
sed -i 's/22\.3\.1/22\.3\.7/' buildyami.sh
sed -i 's/media-driver-$INTEL_MEDIA_DRIVER_SRC_NAME$/--branch $INTEL_MEDIA_DRIVER_SRC_NAME media-driver-$INTEL_MEDIA_DRIVER_SRC_NAME/' buildyami.sh
sed -i 's|prefix=/opt/yami|prefix=/usr/local|' buildyami.sh
sed -i 's|rm -r \$INSTALL_PATH/\*|#rm -r \$INSTALL_PATH/\*|' buildyami.sh
sed -i 's/nproc/(`nproc` - 1)/' buildyami.sh
sed -i 's/-O2 -Wall/-O2 -Wall -Wno-array-compare/g' buildyami.sh
./buildyami.sh --prefix=/usr/local --disable-x11
sudo ln -s /usr/local/lib/x86_64-linux-gnu/dri/i965_drv_video.so /usr/local/lib/x86_64-linux-gnu/
sudo ln -s /usr/local/lib/x86_64-linux-gnu/dri/iHD_drv_video.so /usr/local/lib/x86_64-linux-gnu/
sudo ln -s /usr/local/lib/x86_64-linux-gnu/dri/ /usr/local/lib/dri
echo "Building xrdp..."
git clone https://github.com/Nexarian/xrdp.git --branch mainline_merge "$BUILD_DIR/xrdp"
cd "$BUILD_DIR/xrdp"
sed -i 's|/opt/yami|/usr/local|g' ./sesman/Makefile.am
sed -i 's|/opt/yami|/usr/local|g' ./xorgxrdp_helper/xorgxrdp_helper_yami.c
./bootstrap
XRDP_YAMI_CFLAGS="-I/usr/local/include" XRDP_YAMI_LIBS="-I/usr/local/lib" ./configure \
--enable-fuse --enable-rfxcodec --enable-pixman --enable-mp3lame \
--enable-sound --enable-opus --enable-fdkaac --enable-x264 --enable-yami
make -j $((`nproc` - 1)) clean all
sudo make install
echo "Building xorgxrdp..."
git clone https://github.com/Nexarian/xorgxrdp.git --branch mainline_merge "$BUILD_DIR/xorgxrdp"
cd "$BUILD_DIR/xorgxrdp"
# sed -i 's/#define MIN_MS_BETWEEN_FRAMES 40/#define MIN_MS_BETWEEN_FRAMES 16/' module/rdpClientCon.c
./bootstrap
./configure --with-simd --enable-glamor
make -j $((`nproc` - 1)) clean all
sudo make install
#Pulseaudio xrdp module
PULSE_MODULE_VER="0.7"
cd $BUILD_DIR
wget https://github.com/neutrinolabs/pulseaudio-module-xrdp/archive/v$PULSE_MODULE_VER.tar.gz \
-O pulseaudio-module-xrdp.tar.gz
tar xvzf pulseaudio-module-xrdp.tar.gz
rm pulseaudio-module-xrdp.tar.gz
cd pulseaudio-module-xrdp-$PULSE_MODULE_VER
./scripts/install_pulseaudio_sources_apt.sh -d $BUILD_DIR/pulseaudio.src
./bootstrap
./configure PULSE_DIR=$BUILD_DIR/pulseaudio.src
make
sudo make install
#Allow permission to connect
sudo tee /etc/X11/Xwrapper.config > /dev/null << EOL
# Xwrapper.config (Debian X Window System server wrapper configuration file)
#
# This file was generated by the post-installation script of the
# xserver-xorg-legacy package using values from the debconf database.
#
# See the Xwrapper.config(5) manual page for more information.
#
# This file is automatically updated on upgrades of the xserver-xorg-legacy
# package *only* if it has not been modified since the last upgrade of that
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command as root:
# dpkg-reconfigure xserver-xorg-legacy
needs_root_rights=no
allowed_users=anybody
EOL
#Disable nvidia
sudo sed -i -E 's#param=xrdp/xorg_nvidia.conf#param=xrdp/xorg.conf#' /etc/xrdp/sesman.ini
sudo sed -i 's/XRDP_USE_HELPER=1/XRDP_USE_HELPER=0/' /etc/xrdp/sesman.ini
echo "Starting the server..."
sudo systemctl enable xrdp
sudo service xrdp start
@mattisz
Copy link
Author

mattisz commented Aug 23, 2023

@hjaltioj I just added line 41 to the script. buildyami.sh was grabbing too new of a version of the Intel(R) Media Driver for VAAPI. That version requires newer versions of everything else. This modification brings it back to the Q1 release which supports the GmmLib and Libva versions installed by the script. Now that the Q2 version of the media driver is out, I will probably update the script at some point but no promises that it will be soon so stick with the current modification for now.

@hjaltioj
Copy link

hjaltioj commented Aug 23, 2023

Hello @mattisz
Thank you 👍 its working now :D thanks for your help and amazing script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment