Skip to content

Instantly share code, notes, and snippets.

@larkinwc
Last active October 11, 2024 01:23
Show Gist options
  • Save larkinwc/fdf5f37da67c3ffe7309c043c67a8e67 to your computer and use it in GitHub Desktop.
Save larkinwc/fdf5f37da67c3ffe7309c043c67a8e67 to your computer and use it in GitHub Desktop.
Ubuntu LXC VDI Setup Script
#!/bin/bash
# Ubuntu-22.04-LXC-Desktop Setup Script
# Exit on any error
set -e
# Function to print messages
print_message() {
echo "===== $1 ====="
}
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# Add admin user
print_message "Adding admin user"
adduser admin
usermod -aG sudo admin
# Update sources.list
print_message "Updating sources.list"
cat > /etc/apt/sources.list <<EOL
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu jammy partner
deb-src http://archive.canonical.com/ubuntu jammy partner
EOL
# Update and upgrade
print_message "Updating and upgrading system"
apt update
apt full-upgrade -y
# Install desktop environment
print_message "Installing desktop environment"
DEBIAN_FRONTEND=noninteractive apt install -y xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils
# Install XRDP
print_message "Installing XRDP"
apt install -y xrdp
# Verify XRDP status
systemctl status xrdp
# Set x-session-manager
print_message "Setting x-session-manager"
update-alternatives --set x-session-manager /usr/bin/xfce4-session
# Install Firefox
print_message "Installing Firefox"
apt install -y firefox
# Install latest XRDP with sound support
print_message "Installing latest XRDP with sound support"
cd /opt
wget https://www.c-nergy.be/downloads/xRDP/xrdp-installer-1.4.2.zip
unzip xrdp-installer-1.4.2.zip
chmod +x xrdp-installer-1.4.2.sh
./xrdp-installer-1.4.2.sh
print_message "Setup complete. Please reboot the container."
echo "After reboot, run 'pulseaudio -k' as the admin user to fix audio issues."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment