netgescon-master/scripts/install-vscode-netgescon.sh

174 lines
5.7 KiB
Bash

#!/bin/bash
# install-vscode-netgescon.sh - Script completo per VS Code + NetGescon
# Versione ottimizzata per Ubuntu 24.04 LTS
echo "🚀 Installazione Visual Studio Code per NetGescon"
echo "================================================="
# Verifica che siamo su Ubuntu
if ! command -v lsb_release &> /dev/null || [[ $(lsb_release -si) != "Ubuntu" ]]; then
echo "❌ Questo script è progettato per Ubuntu"
exit 1
fi
echo "📍 Sistema: $(lsb_release -d | cut -f2)"
echo "📍 Utente: $(whoami)"
echo ""
# 1. Aggiorna sistema
echo "🔄 Aggiornamento sistema..."
sudo apt update && sudo apt upgrade -y
# 2. Installa prerequisiti
echo "📦 Installazione prerequisiti..."
sudo apt install -y wget gpg software-properties-common apt-transport-https curl git openssh-server
# 3. Installa VS Code tramite repository Microsoft
echo "💻 Installazione Visual Studio Code..."
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt update && sudo apt install -y code
# 4. Verifica installazione VS Code
if command -v code &> /dev/null; then
echo "✅ VS Code installato: $(code --version | head -n1)"
else
echo "❌ Errore installazione VS Code"
exit 1
fi
# 5. Installa estensioni NetGescon essenziali
echo "🔧 Installazione estensioni per Laravel/PHP..."
# Estensioni PHP/Laravel
code --install-extension bmewburn.vscode-intelephense-client
code --install-extension onecentlin.laravel5-snippets
code --install-extension onecentlin.laravel-blade
code --install-extension ryannaddy.laravel-artisan
code --install-extension codingyu.laravel-goto-view
# Estensioni sviluppo web
code --install-extension ms-vscode.vscode-json
code --install-extension bradlc.vscode-tailwindcss
code --install-extension formulahendry.auto-rename-tag
code --install-extension christian-kohler.path-intellisense
code --install-extension streetsidesoftware.code-spell-checker
# Estensioni Git e collaborazione
code --install-extension eamodio.gitlens
code --install-extension mhutchie.git-graph
code --install-extension ms-vscode-remote.remote-ssh
# Estensioni tema e produttività
code --install-extension PKief.material-icon-theme
# 6. Configura SSH per accesso remoto
echo "🔐 Configurazione SSH..."
sudo systemctl enable ssh && sudo systemctl start ssh
sudo ufw allow ssh
if ! sudo ufw status | grep -q "Status: active"; then
sudo ufw --force enable
fi
# 7. Crea configurazione VS Code per NetGescon
echo "⚙️ Configurazione VS Code per NetGescon..."
mkdir -p ~/.config/Code/User
cat > ~/.config/Code/User/settings.json << 'EOF'
{
"workbench.colorTheme": "Default Dark Modern",
"workbench.iconTheme": "material-icon-theme",
"editor.fontSize": 14,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.rulers": [80, 120],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 120,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"terminal.integrated.fontSize": 12,
"php.suggest.basic": false,
"intelephense.files.maxSize": 5000000,
"intelephense.format.braces": "k&r",
"blade.format.enable": true,
"laravel_goto_view.folders": {
"default": "resources/views",
"modules": "Modules/{module}/Resources/views"
},
"emmet.includeLanguages": {
"blade": "html"
},
"files.associations": {
"*.blade.php": "blade"
},
"git.autofetch": true,
"git.confirmSync": false,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"breadcrumbs.enabled": true,
"editor.minimap.enabled": true,
"workbench.editor.enablePreview": false,
"workbench.startupEditor": "none"
}
EOF
# 8. Crea workspace NetGescon
if [ -d "/var/www/netgescon" ]; then
echo "🎯 Creazione workspace NetGescon..."
cat > ~/.config/Code/User/netgescon.code-workspace << EOF
{
"folders": [
{
"name": "NetGescon",
"path": "/var/www/netgescon"
}
],
"settings": {
"php.validate.executablePath": "/usr/bin/php",
"terminal.integrated.cwd": "/var/www/netgescon"
},
"extensions": {
"recommendations": [
"bmewburn.vscode-intelephense-client",
"onecentlin.laravel5-snippets",
"onecentlin.laravel-blade",
"ryannaddy.laravel-artisan"
]
}
}
EOF
fi
# 9. Test finale
echo ""
echo "🧪 Test installazione..."
code --list-extensions | grep -q "bmewburn.vscode-intelephense-client" && echo "✅ Estensioni PHP OK"
systemctl is-active --quiet ssh && echo "✅ SSH Server attivo"
# 10. Informazioni finali
echo ""
echo "🎉 Installazione completata!"
echo "============================================="
echo "✅ Visual Studio Code: $(code --version | head -n1)"
echo "✅ Estensioni installate: $(code --list-extensions | wc -l)"
echo "📍 IP VM: $(hostname -I | awk '{print $1}')"
echo "🔗 Connessione SSH: ssh $(whoami)@$(hostname -I | awk '{print $1}')"
echo "📁 Configurazione: ~/.config/Code/User/"
echo ""
echo "🚀 Prossimi step:"
echo "1. Connetti da Windows con VS Code Remote-SSH"
echo "2. Apri il progetto NetGescon: code /var/www/netgescon"
echo "3. Configura Git: git config --global user.name 'Nome'"
echo "4. Inizia lo sviluppo!"
echo ""
# Opzionale: avvia VS Code se siamo in ambiente desktop
if [ "$DISPLAY" ]; then
read -p "🖥️ Vuoi avviare VS Code ora? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
code &
fi
fi