Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script simplificado para configurar XRDP no Manjaro para Hyper-V Enhanced Session
- # Baseado no script do Chris Titus Tech, mas corrigido para Manjaro
- set -e # Parar em caso de erro
- echo "=== Configurando XRDP para Hyper-V Enhanced Session no Manjaro ==="
- # Verificar se é root
- if [ "$(id -u)" -ne 0 ]; then
- echo "❌ Este script deve ser executado como root"
- echo "💡 Use: sudo $0"
- exit 1
- fi
- # Função para verificar se comando existe
- command_exists() {
- command -v "$1" >/dev/null 2>&1
- }
- # Verificar se yay está instalado (AUR helper)
- if ! command_exists yay; then
- echo "📦 Instalando yay (AUR helper)..."
- pacman -S --needed --noconfirm base-devel git
- # Criar usuário temporário para build se necessário
- if [ ! -d "/tmp/yay-install" ]; then
- mkdir -p /tmp/yay-install
- cd /tmp/yay-install
- # Como root, precisamos fazer isso diferente
- sudo -u nobody git clone https://aur.archlinux.org/yay.git || {
- echo "⚠️ Erro ao clonar yay. Instalando pacotes AUR manualmente..."
- MANUAL_INSTALL=1
- }
- fi
- fi
- # Instalar XRDP
- echo "📦 Instalando XRDP e dependências..."
- if [ "$MANUAL_INSTALL" = "1" ]; then
- # Instalação manual dos pacotes necessários
- pacman -S --needed --noconfirm openssh
- echo "⚠️ XRDP precisa ser instalado manualmente do AUR"
- echo "💡 Execute após este script: yay -S xrdp xorgxrdp-devel-git"
- SKIP_XRDP_CONFIG=1
- else
- # Tentar com yay
- if command_exists yay; then
- echo "📦 Instalando XRDP via yay..."
- yay -S --needed --noconfirm xrdp xorgxrdp-devel-git || {
- echo "⚠️ Erro na instalação via yay. Continuando..."
- SKIP_XRDP_CONFIG=1
- }
- fi
- fi
- # Instalar dependências básicas
- echo "📦 Instalando dependências do sistema..."
- pacman -S --needed --noconfirm \
- openssh \
- polkit \
- xorg-server \
- xorg-xinit
- # Configurar XRDP (apenas se foi instalado com sucesso)
- if [ "$SKIP_XRDP_CONFIG" != "1" ] && [ -f "/etc/xrdp/xrdp.ini" ]; then
- echo "⚙️ Configurando XRDP para Hyper-V..."
- # Backup das configurações originais
- cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.backup
- cp /etc/xrdp/sesman.ini /etc/xrdp/sesman.ini.backup
- # Configurar para vsock (Hyper-V Enhanced Session)
- sed -i 's/port=3389/port=vsock:\/\/-1:3389/g' /etc/xrdp/xrdp.ini
- sed -i 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini
- sed -i 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini
- sed -i 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini
- # Configurar drives compartilhados
- sed -i 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini
- # Habilitar serviços
- systemctl enable xrdp
- systemctl enable xrdp-sesman
- echo "✅ XRDP configurado com sucesso!"
- else
- echo "⚠️ XRDP não foi configurado automaticamente"
- fi
- # Configurar X11
- echo "⚙️ Configurando X11..."
- echo "allowed_users=anybody" > /etc/X11/Xwrapper.config
- # Configurar módulo Hyper-V
- echo "⚙️ Configurando módulo hv_sock..."
- if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then
- echo "hv_sock" > /etc/modules-load.d/hv_sock.conf
- fi
- # Configurar polkit para evitar prompts de senha
- echo "⚙️ Configurando políticas de sistema..."
- cat > /etc/polkit-1/rules.d/02-allow-colord.rules <<EOF
- polkit.addRule(function(action, subject) {
- if ((action.id == "org.freedesktop.color-manager.create-device" ||
- action.id == "org.freedesktop.color-manager.modify-profile" ||
- action.id == "org.freedesktop.color-manager.delete-device" ||
- action.id == "org.freedesktop.color-manager.create-profile" ||
- action.id == "org.freedesktop.color-manager.modify-profile" ||
- action.id == "org.freedesktop.color-manager.delete-profile") &&
- subject.isInGroup("users"))
- {
- return polkit.Result.YES;
- }
- });
- EOF
- # Configurar PAM para XRDP
- echo "⚙️ Configurando autenticação..."
- cat > /etc/pam.d/xrdp-sesman <<EOF
- #%PAM-1.0
- auth include system-remote-login
- account include system-remote-login
- password include system-remote-login
- session include system-remote-login
- EOF
- # Habilitar SSH
- echo "⚙️ Habilitando SSH..."
- systemctl enable sshd
- echo ""
- echo "🎉 Configuração básica concluída!"
- echo ""
- echo "📋 PRÓXIMOS PASSOS:"
- echo ""
- if [ "$SKIP_XRDP_CONFIG" = "1" ]; then
- echo "1. ⚠️ Instalar XRDP manualmente:"
- echo " yay -S xrdp xorgxrdp-devel-git"
- echo ""
- echo "2. 🔄 Executar este script novamente após instalar XRDP"
- echo ""
- fi
- echo "3. 🖥️ Configurar .xinitrc para seu desktop environment:"
- echo " echo 'exec startxfce4' > ~/.xinitrc # Para XFCE"
- echo " echo 'exec i3' > ~/.xinitrc # Para i3"
- echo " echo 'exec gnome-session' > ~/.xinitrc # Para GNOME"
- echo ""
- echo "4. 🔄 Reiniciar a VM:"
- echo " sudo reboot"
- echo ""
- echo "5. 🔗 Conectar via Enhanced Session Mode no Hyper-V Manager"
- echo ""
- echo "💡 Para Hyprland (Wayland), use i3 ou outro WM X11 para XRDP!"
- echo ""
Advertisement
Add Comment
Please, Sign In to add comment