#!/bin/bash # Script to install Steam in an unprivileged LXC container with GPU passthrough # This script should be run as root set -e # Exit on error # Colors for output GREEN='\033[0;32m' RED='\033[0;31m' NC='\033[0m' # No Color # Function to print status messages print_status() { echo -e "${GREEN}[*] $1${NC}" } # Function to print error messages print_error() { echo -e "${RED}[ERROR] $1${NC}" exit 1 } # Check if running as root if [ "$EUID" -ne 0 ]; then print_error "Please run this script as root" fi # Get username for the new user read -p "Enter the desired username: " USERNAME if [ -z "$USERNAME" ]; then print_error "Username cannot be empty" fi print_status "Starting installation process..." # 1. Update and upgrade packages print_status "Updating and upgrading packages..." apt update || print_error "Failed to update package list" apt upgrade -y || print_error "Failed to upgrade packages" # 2. Install required packages print_status "Installing required packages..." apt install -y sudo wget || print_error "Failed to install basic packages" # 3. Create new user and add to required groups print_status "Creating new user: $USERNAME" adduser "$USERNAME" || print_error "Failed to create user" usermod -aG render "$USERNAME" || print_error "Failed to add user to render group" usermod -aG sudo "$USERNAME" || print_error "Failed to add user to sudo group" usermod -aG ssl-cert "$USERNAME" || print_error "Failed to add user to ssl-cert group" # 4. Install MATE desktop environment print_status "Installing MATE desktop environment..." apt install -y mate-desktop-environment || print_error "Failed to install MATE desktop" # 5. Install KasmVNC print_status "Installing KasmVNC..." cd /tmp || print_error "Failed to change to /tmp directory" wget https://github.com/kasmtech/KasmVNC/releases/download/v1.2.0/kasmvncserver_bookworm_1.2.0_amd64.deb || print_error "Failed to download KasmVNC" apt install -y ./kasmvncserver_*.deb || print_error "Failed to install KasmVNC" # 6. Install Steam and dependencies print_status "Installing Steam and dependencies..." dpkg --add-architecture i386 || print_error "Failed to add i386 architecture" apt update || print_error "Failed to update package list" cd /tmp || print_error "Failed to change to /tmp directory" wget https://cdn.akamai.steamstatic.com/client/installer/steam.deb || print_error "Failed to download Steam" # Install Steam and its dependencies apt install -y ./steam.deb || print_error "Failed to install Steam" apt install -y \ libc6-i386 \ libgl1:i386 \ libdrm2:i386 \ libc6:amd64 \ libc6:i386 \ libegl1:amd64 \ libegl1:i386 \ libgbm1:amd64 \ libgbm1:i386 \ libgl1-mesa-dri:amd64 \ libgl1-mesa-dri:i386 \ libgl1:amd64 \ libgl1:i386 \ steam-libs-amd64:amd64 \ steam-libs-i386:i386 || print_error "Failed to install Steam dependencies" # Clean up downloaded files rm -f /tmp/steam.deb /tmp/kasmvncserver_*.deb print_status "Installation completed successfully!" print_status "Please switch to user '$USERNAME' and run: vncserver -hw3d -drinode /dev/dri/renderD128" print_status "Note: Always use the above command to start KasmVNC to ensure GPU passthrough is enabled" print_status "Important: It's recommended to disable desktop compositing for better performance" print_status "You can start Steam by running the 'steam' command or using the desktop shortcut"