Skip to content

Instantly share code, notes, and snippets.

@davidlatwe
Forked from Nexarian/xrdp-nvidia-setup.sh
Created March 22, 2024 16:13
Show Gist options
  • Save davidlatwe/f26d3b17afc316c1bae40ef4222024d8 to your computer and use it in GitHub Desktop.
Save davidlatwe/f26d3b17afc316c1bae40ef4222024d8 to your computer and use it in GitHub Desktop.

Revisions

  1. @Nexarian Nexarian revised this gist Aug 1, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,8 @@ sudo apt-get -y dist-upgrade
    sudo apt-get -y autoremove

    # Install CUDA (Shamelessly copied from Nvidia's website):
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
    sudo dpkg -i cuda-keyring_1.0-1_all.deb
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
    sudo dpkg -i cuda-keyring_1.1-1_all.deb
    sudo apt-get update
    sudo apt-get -y install cuda

  2. @Nexarian Nexarian revised this gist Mar 28, 2023. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -56,6 +56,15 @@ needs_root_rights=no
    allowed_users=anybody
    EOL

    echo "gnome-session --session=ubuntu" > ~/.xsession
    sudo chmod +x ~/.xsession
    sudo tee ~/.xsessionrc > /dev/null << EOL
    export DESKTOP_SESSION=ubuntu
    export GNOME_SHELL_SESSION_MODE=ubuntu
    export XDG_CURRENT_DESKTOP=ubuntu:GNOME
    EOL
    sudo chmod +x ~/.xsessionrc

    BUILD_DIR=$(mktemp -d)

    echo "Building xrdp..."
  3. @Nexarian Nexarian revised this gist Jan 2, 2023. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -22,12 +22,13 @@ sudo usermod $USER -a -G tty
    sudo usermod $USER -a -G render

    # XRDP Build Pre-reqs Part 1
    sudo apt-get -y install 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
    sudo apt-get -y install 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

    #XRDP Build Pre-reqs Part 2 (For some reason apt needs this to be separate)
    sudo apt-get -y install libepoxy-dev
  4. @Nexarian Nexarian revised this gist Dec 9, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -63,15 +63,15 @@ cd "$BUILD_DIR/xrdp"
    ./bootstrap
    ./configure --enable-fuse --enable-rfxcodec --enable-pixman --enable-mp3lame \
    --enable-sound --enable-opus --enable-fdkaac --enable-x264 --enable-nvenc
    make clean all
    make -j $(nproc) 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"
    ./bootstrap
    ./configure --with-simd --enable-lrandr
    make clean all
    make -j $(nproc) clean all
    sudo make install

    echo "Configuring Nvidia..."
  5. @Nexarian Nexarian revised this gist Dec 2, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -78,6 +78,7 @@ echo "Configuring Nvidia..."
    BUS_ID=$(nvidia-smi --query-gpu=pci.bus --format=csv | sed -n '2 p' | xargs -I{} printf "%d\n" {})
    # Alternative method to get the BUS ID that doesn't work on some systems (Such as a laptop with an Intel iGPU and an Nvidia Discrete GPU).
    # BUS_ID=$(lspci | grep -e 'VGA.*NVIDIA' | cut -d: -f1 | xargs -I{} printf "%d\n" 0x{} | sed -n 1p)
    # nvidia-xconfig --query-gpu-info
    sudo sed -i -E 's/(BusID "PCI:)[[:digit:]]+(:0:0")/\1'$BUS_ID'\2/' /etc/X11/xrdp/xorg_nvidia.conf

    echo "Starting the server..."
  6. @Nexarian Nexarian revised this gist Nov 26, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -76,7 +76,7 @@ sudo make install

    echo "Configuring Nvidia..."
    BUS_ID=$(nvidia-smi --query-gpu=pci.bus --format=csv | sed -n '2 p' | xargs -I{} printf "%d\n" {})
    # Alternative method to get the BUS ID that doesn't work on systems with more than one video card.
    # Alternative method to get the BUS ID that doesn't work on some systems (Such as a laptop with an Intel iGPU and an Nvidia Discrete GPU).
    # BUS_ID=$(lspci | grep -e 'VGA.*NVIDIA' | cut -d: -f1 | xargs -I{} printf "%d\n" 0x{} | sed -n 1p)
    sudo sed -i -E 's/(BusID "PCI:)[[:digit:]]+(:0:0")/\1'$BUS_ID'\2/' /etc/X11/xrdp/xorg_nvidia.conf

  7. @Nexarian Nexarian revised this gist Nov 26, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -75,7 +75,9 @@ make clean all
    sudo make install

    echo "Configuring Nvidia..."
    BUS_ID=$(lspci | grep -e 'VGA.*NVIDIA' | cut -d: -f1 | xargs -I{} printf "%d\n" 0x{} | sed -n 1p)
    BUS_ID=$(nvidia-smi --query-gpu=pci.bus --format=csv | sed -n '2 p' | xargs -I{} printf "%d\n" {})
    # Alternative method to get the BUS ID that doesn't work on systems with more than one video card.
    # BUS_ID=$(lspci | grep -e 'VGA.*NVIDIA' | cut -d: -f1 | xargs -I{} printf "%d\n" 0x{} | sed -n 1p)
    sudo sed -i -E 's/(BusID "PCI:)[[:digit:]]+(:0:0")/\1'$BUS_ID'\2/' /etc/X11/xrdp/xorg_nvidia.conf

    echo "Starting the server..."
  8. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,6 @@ sudo apt-get -y update
    sudo apt-get -y dist-upgrade
    sudo apt-get -y autoremove

    cd ~
    # Install CUDA (Shamelessly copied from Nvidia's website):
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
    sudo dpkg -i cuda-keyring_1.0-1_all.deb
  9. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ sudo apt-get -y update
    sudo apt-get -y dist-upgrade
    sudo apt-get -y autoremove

    cd ~
    # Install CUDA (Shamelessly copied from Nvidia's website):
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
    sudo dpkg -i cuda-keyring_1.0-1_all.deb
  10. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -12,10 +12,8 @@ sudo apt-get -y dist-upgrade
    sudo apt-get -y autoremove

    # Install CUDA (Shamelessly copied from Nvidia's website):
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
    sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
    sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
    sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
    sudo dpkg -i cuda-keyring_1.0-1_all.deb
    sudo apt-get update
    sudo apt-get -y install cuda

  11. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/bin/bash
    #!/usr/bin/env bash

    set -e

    @@ -35,7 +35,7 @@ sudo apt-get -y install git autoconf libtool pkg-config gcc g++ make libssl-dev
    sudo apt-get -y install libepoxy-dev

    #System Pre-reqs
    sudo apt-get -y install xorg xserver-xorg-legacy dbus-x11 mate-desktop-environment compton
    sudo apt-get -y install xorg xserver-xorg-legacy dbus-x11
    sudo apt-get -y remove dbus-user-session

    sudo tee /etc/X11/Xwrapper.config > /dev/null << EOL
    @@ -57,8 +57,6 @@ needs_root_rights=no
    allowed_users=anybody
    EOL

    echo "mate-session" > ~/.xsession

    BUILD_DIR=$(mktemp -d)

    echo "Building xrdp..."
  12. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,7 @@ sudo apt-get -y install cuda

    sudo usermod $USER -a -G video
    sudo usermod $USER -a -G tty
    sudo usermod $USER -a -G render

    # XRDP Build Pre-reqs Part 1
    sudo apt-get -y install git autoconf libtool pkg-config gcc g++ make libssl-dev libpam0g-dev \
  13. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ sudo usermod $USER -a -G tty
    # XRDP Build Pre-reqs Part 1
    sudo apt-get -y install 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 python-libxml2 g++ xutils libfuse-dev libmp3lame-dev nasm libpixman-1-dev \
    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
    @@ -73,7 +73,7 @@ echo "Building xorgxrdp..."
    git clone https://github.com/Nexarian/xorgxrdp.git --branch mainline_merge "$BUILD_DIR/xorgxrdp"
    cd "$BUILD_DIR/xorgxrdp"
    ./bootstrap
    ./configure --with-simd
    ./configure --with-simd --enable-lrandr
    make clean all
    sudo make install

  14. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@

    Updated version of the install script for Nvidia use-cases

    #!/bin/bash

    set -e
  15. @Nexarian Nexarian revised this gist Nov 25, 2022. 1 changed file with 89 additions and 1 deletion.
    90 changes: 89 additions & 1 deletion xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -1 +1,89 @@
    #Placeholder

    Updated version of the install script for Nvidia use-cases

    #!/bin/bash

    set -e

    cd ~

    sudo -v

    # Make sure system is in a good, updated, clean, state.
    sudo apt-get -y update
    sudo apt-get -y dist-upgrade
    sudo apt-get -y autoremove

    # Install CUDA (Shamelessly copied from Nvidia's website):
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
    sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
    sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
    sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
    sudo apt-get update
    sudo apt-get -y install cuda

    sudo usermod $USER -a -G video
    sudo usermod $USER -a -G tty

    # XRDP Build Pre-reqs Part 1
    sudo apt-get -y install 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 python-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

    #XRDP Build Pre-reqs Part 2 (For some reason apt needs this to be separate)
    sudo apt-get -y install libepoxy-dev

    #System Pre-reqs
    sudo apt-get -y install xorg xserver-xorg-legacy dbus-x11 mate-desktop-environment compton
    sudo apt-get -y remove dbus-user-session

    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

    echo "mate-session" > ~/.xsession

    BUILD_DIR=$(mktemp -d)

    echo "Building xrdp..."
    git clone https://github.com/Nexarian/xrdp.git --branch mainline_merge "$BUILD_DIR/xrdp"
    cd "$BUILD_DIR/xrdp"
    ./bootstrap
    ./configure --enable-fuse --enable-rfxcodec --enable-pixman --enable-mp3lame \
    --enable-sound --enable-opus --enable-fdkaac --enable-x264 --enable-nvenc
    make 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"
    ./bootstrap
    ./configure --with-simd
    make clean all
    sudo make install

    echo "Configuring Nvidia..."
    BUS_ID=$(lspci | grep -e 'VGA.*NVIDIA' | cut -d: -f1 | xargs -I{} printf "%d\n" 0x{} | sed -n 1p)
    sudo sed -i -E 's/(BusID "PCI:)[[:digit:]]+(:0:0")/\1'$BUS_ID'\2/' /etc/X11/xrdp/xorg_nvidia.conf

    echo "Starting the server..."
    sudo systemctl enable xrdp
    sudo service xrdp start
  16. @Nexarian Nexarian created this gist Nov 25, 2022.
    1 change: 1 addition & 0 deletions xrdp-nvidia-setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    #Placeholder