netgescon-master/fix-vscode-install.sh
2025-07-20 14:57:25 +00:00

83 lines
2.7 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Script per risolvere conflitti repository Microsoft e installare VS Code
echo "🔧 RISOLUZIONE CONFLITTI REPOSITORY MICROSOFT"
echo "=============================================="
echo "1⃣ Pulizia configurazioni conflittuali..."
# Rimuovi configurazioni duplicate
sudo rm -f /etc/apt/sources.list.d/vscode.list
sudo rm -f /etc/apt/trusted.gpg.d/packages.microsoft.gpg
sudo rm -f /usr/share/keyrings/microsoft.gpg
echo "2⃣ Configurazione pulita repository Microsoft..."
# Download chiave GPG in posizione standard
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg
# Configura repository VS Code con riferimento corretto alla chiave
echo "deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
echo "3⃣ Aggiornamento liste pacchetti..."
sudo apt update
echo "4⃣ Installazione VS Code..."
sudo apt install -y code
echo "5⃣ Test installazione..."
if command -v code &> /dev/null; then
echo "✅ VS Code installato correttamente!"
code --version
else
echo "❌ Problema con l'installazione"
exit 1
fi
echo ""
echo "6⃣ Configurazione ambiente desktop..."
# Controlla se GNOME è installato
if command -v gnome-session &> /dev/null; then
echo "✅ GNOME già installato"
elif command -v startx &> /dev/null; then
echo "✅ X11 disponibile"
else
echo "📱 Installazione ambiente desktop minimale..."
sudo apt install -y ubuntu-desktop-minimal
echo "⚠️ RIAVVIO NECESSARIO per attivare l'interfaccia grafica"
fi
echo ""
echo "7⃣ Configurazione accesso remoto (opzionale)..."
read -p "Vuoi installare il desktop remoto (RDP)? (y/n): " install_rdp
if [[ $install_rdp =~ ^[Yy]$ ]]; then
sudo apt install -y xrdp
sudo systemctl enable xrdp
sudo systemctl start xrdp
# Configura firewall se ufw è attivo
if command -v ufw &> /dev/null && sudo ufw status | grep -q "Status: active"; then
sudo ufw allow 3389
echo "✅ Firewall configurato per RDP (porta 3389)"
fi
echo "✅ Desktop remoto configurato"
echo "<22><> Connessione RDP: 192.168.0.200:3389"
fi
echo ""
echo "✅ CONFIGURAZIONE COMPLETATA!"
echo ""
echo "📋 Prossimi passi:"
echo "1. Riavvia il sistema se richiesto: sudo reboot"
echo "2. Avvia VS Code: code /var/www/netgescon"
echo "3. Se usi RDP, connettiti a: 192.168.0.200:3389"
echo ""
echo "🛠️ Comandi utili:"
echo "- Test VS Code: code --version"
echo "- Apri progetto: code /var/www/netgescon"
echo "- Stato desktop remoto: sudo systemctl status xrdp"