364 lines
12 KiB
Bash
Executable File
364 lines
12 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script di installazione automatica per Ubuntu
|
|
# Eseguire con: bash ubuntu-setup.sh
|
|
|
|
set -e # Interrompe lo script se c'è un errore
|
|
|
|
# Colori per output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Funzione per stampare messaggi colorati
|
|
print_status() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Funzione per controllare se un comando è riuscito
|
|
check_command() {
|
|
if [ $? -eq 0 ]; then
|
|
print_success "$1 installato con successo"
|
|
else
|
|
print_error "Errore nell'installazione di $1"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
print_status "Inizio installazione automatica Ubuntu..."
|
|
|
|
# Aggiornamento sistema
|
|
print_status "Aggiornamento sistema..."
|
|
sudo apt update && sudo apt upgrade -y
|
|
check_command "Aggiornamento sistema"
|
|
|
|
# Installazione dipendenze base
|
|
print_status "Installazione dipendenze base..."
|
|
sudo apt install -y curl wget gpg software-properties-common apt-transport-https ca-certificates gnupg lsb-release
|
|
check_command "Dipendenze base"
|
|
|
|
# === GOOGLE CHROME ===
|
|
print_status "Installazione Google Chrome..."
|
|
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrome-keyring.gpg
|
|
sudo tee /etc/apt/sources.list.d/google-chrome.sources > /dev/null <<EOF
|
|
Types: deb
|
|
URIs: http://dl.google.com/linux/chrome/deb/
|
|
Suites: stable
|
|
Components: main
|
|
Architectures: amd64
|
|
Signed-By: /usr/share/keyrings/googlechrome-keyring.gpg
|
|
EOF
|
|
sudo apt update
|
|
sudo apt install -y google-chrome-stable
|
|
check_command "Google Chrome"
|
|
|
|
# === VISUAL STUDIO CODE ===
|
|
print_status "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 tee /etc/apt/sources.list.d/vscode.sources > /dev/null <<EOF
|
|
Types: deb
|
|
URIs: https://packages.microsoft.com/repos/code
|
|
Suites: stable
|
|
Components: main
|
|
Architectures: amd64 arm64 armhf
|
|
Signed-By: /etc/apt/trusted.gpg.d/packages.microsoft.gpg
|
|
EOF
|
|
sudo apt update
|
|
sudo apt install -y code
|
|
check_command "Visual Studio Code"
|
|
|
|
# Creazione profili e installazione estensioni VS Code
|
|
print_status "Creazione profili e installazione estensioni VS Code..."
|
|
|
|
# Aspetta che VS Code sia completamente installato
|
|
sleep 2
|
|
|
|
# Prima creiamo i profili avviando VS Code con ciascun profilo
|
|
print_status "Creazione profili VS Code..."
|
|
|
|
# Funzione per creare un profilo
|
|
create_vscode_profile() {
|
|
local profile_name="$1"
|
|
print_status "Creando profilo $profile_name..."
|
|
|
|
# Avvia VS Code con il profilo per crearlo, poi lo chiude subito
|
|
timeout 10 code --profile "$profile_name" --wait /tmp 2>/dev/null || true
|
|
sleep 2
|
|
|
|
# Chiude tutte le istanze di VS Code
|
|
pkill -f "code.*$profile_name" 2>/dev/null || true
|
|
sleep 1
|
|
}
|
|
|
|
# Crea i profili
|
|
create_vscode_profile "Default"
|
|
create_vscode_profile "Python"
|
|
create_vscode_profile "Rust"
|
|
create_vscode_profile "Web"
|
|
|
|
print_success "Profili VS Code creati"
|
|
|
|
# Ora installiamo le estensioni per ogni profilo
|
|
print_status "Installazione estensioni per profilo Default..."
|
|
#code --profile "Default" --install-extension ms-vscode.vscode-git
|
|
code --profile "Default" --install-extension pkief.material-icon-theme
|
|
check_command "Estensioni profilo Default"
|
|
|
|
print_status "Installazione estensioni per profilo Python..."
|
|
code --profile "Python" --install-extension ms-python.python
|
|
code --profile "Python" --install-extension ms-python.flake8
|
|
code --profile "Python" --install-extension charliermarsh.ruff
|
|
code --profile "Python" --install-extension ms-python.pylint
|
|
code --profile "Python" --install-extension ms-python.black-formatter
|
|
check_command "Estensioni profilo Python"
|
|
|
|
print_status "Installazione estensioni per profilo Rust..."
|
|
code --profile "Rust" --install-extension rust-lang.rust-analyzer
|
|
code --profile "Rust" --install-extension vadimcn.vscode-lldb
|
|
code --profile "Rust" --install-extension serayuzgur.crates
|
|
check_command "Estensioni profilo Rust"
|
|
|
|
print_status "Installazione estensioni per profilo Web..."
|
|
code --profile "Web" --install-extension ms-vscode.vscode-typescript-next
|
|
code --profile "Web" --install-extension bradlc.vscode-tailwindcss
|
|
code --profile "Web" --install-extension formulahendry.auto-rename-tag
|
|
code --profile "Web" --install-extension esbenp.prettier-vscode
|
|
check_command "Estensioni profilo Web"
|
|
|
|
print_success "Tutti i profili VS Code configurati (Default, Python, Rust, Web)"
|
|
|
|
# === FILEZILLA ===
|
|
print_status "Installazione FileZilla..."
|
|
sudo apt install -y filezilla
|
|
check_command "FileZilla"
|
|
|
|
# === DBEAVER ===
|
|
print_status "Installazione DBeaver..."
|
|
curl -fsSL https://dbeaver.io/debs/dbeaver.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/dbeaver.gpg
|
|
sudo tee /etc/apt/sources.list.d/dbeaver.sources > /dev/null <<EOF
|
|
Types: deb
|
|
URIs: https://dbeaver.io/debs/dbeaver-ce
|
|
Suites: /
|
|
Components:
|
|
Signed-By: /usr/share/keyrings/dbeaver.gpg
|
|
EOF
|
|
sudo apt update
|
|
sudo apt install -y dbeaver-ce
|
|
check_command "DBeaver"
|
|
|
|
# === WARP TERMINAL ===
|
|
print_status "Installazione Warp Terminal..."
|
|
curl -fsSL https://releases.warp.dev/linux/keys/warp.asc | sudo gpg --dearmor -o /usr/share/keyrings/warp.gpg
|
|
sudo tee /etc/apt/sources.list.d/warp.sources > /dev/null <<EOF
|
|
Types: deb
|
|
URIs: https://releases.warp.dev/linux/deb
|
|
Suites: stable
|
|
Components: main
|
|
Architectures: amd64
|
|
Signed-By: /usr/share/keyrings/warp.gpg
|
|
EOF
|
|
sudo apt update
|
|
sudo apt install -y warp-terminal
|
|
check_command "Warp Terminal"
|
|
|
|
# === INSOMNIA ===
|
|
print_status "Installazione Insomnia..."
|
|
sudo snap install insomnia
|
|
check_command "Insomnia"
|
|
|
|
# === MQTTX ===
|
|
print_status "Installazione MQTTX..."
|
|
sudo snap install mqttx
|
|
check_command "MQTTX"
|
|
|
|
# === STRUMENTI SVILUPPO ===
|
|
print_status "Installazione strumenti di sviluppo..."
|
|
|
|
# Git (potrebbe già essere installato)
|
|
sudo apt install -y git
|
|
check_command "Git"
|
|
|
|
# Python
|
|
sudo apt install -y python3
|
|
check_command "Python3"
|
|
|
|
# Rust
|
|
print_status "Installazione Rust..."
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
source ~/.cargo/env
|
|
check_command "Rust"
|
|
|
|
# UV (Python package manager)
|
|
print_status "Installazione UV..."
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
source ~/.local/bin/env
|
|
check_command "UV"
|
|
|
|
# Ruff (Python linter)
|
|
# print_status "Installazione Ruff..."
|
|
# pip3 install --user ruff
|
|
# check_command "Ruff"
|
|
|
|
# === INCUS ===
|
|
print_status "Installazione Incus..."
|
|
|
|
# Aggiunta repository Zabbly per Incus
|
|
sudo mkdir -p /etc/apt/keyrings/
|
|
curl -fsSL https://pkgs.zabbly.com/key.asc | sudo gpg --dearmor -o /etc/apt/keyrings/zabbly.gpg
|
|
sudo tee /etc/apt/sources.list.d/zabbly-incus.sources > /dev/null <<EOF
|
|
Types: deb
|
|
URIs: https://pkgs.zabbly.com/incus/stable
|
|
Suites: noble
|
|
Components: main
|
|
Signed-By: /etc/apt/keyrings/zabbly.gpg
|
|
EOF
|
|
sudo apt update
|
|
|
|
# Installazione Incus
|
|
sudo apt install -y incus incus-ui-canonical
|
|
check_command "Incus"
|
|
|
|
# Configurazione iniziale Incus
|
|
print_status "Configurazione iniziale Incus..."
|
|
sudo incus admin init
|
|
sudo usermod -a -G incus-admin $USER
|
|
print_warning "Disconnettiti e riconnettiti per applicare i permessi di gruppo per Incus"
|
|
|
|
# === PULIZIA FINALE ===
|
|
print_status "Pulizia finale..."
|
|
sudo apt autoremove -y
|
|
sudo apt autoclean
|
|
|
|
# === RIPRISTINO FILE .DESKTOP DA GITEA ===
|
|
print_status "Download file .desktop dal repository Gitea..."
|
|
|
|
# Directory per i file .desktop dell'utente
|
|
DESKTOP_DIR="$HOME/.local/share/applications"
|
|
TEMP_REPO_DIR="/tmp/desktop-app-repo"
|
|
|
|
# Crea la directory se non esiste
|
|
mkdir -p "$DESKTOP_DIR"
|
|
|
|
# Rimuovi directory temporanea se esiste
|
|
rm -rf "$TEMP_REPO_DIR"
|
|
|
|
# Clone del repository con autenticazione
|
|
print_status "Cloning repository alex/desktop-app..."
|
|
if git clone "https://$GITEA_USERNAME:$GITEA_PASSWORD@gitbat.duckdns.org:44443/alex/desktop-app.git" "$TEMP_REPO_DIR" 2>/dev/null; then
|
|
print_success "Repository clonato con successo"
|
|
|
|
# Copia tutti i file .desktop dal repository
|
|
if [ -d "$TEMP_REPO_DIR" ] && [ "$(ls -A $TEMP_REPO_DIR/*.desktop 2>/dev/null)" ]; then
|
|
cp "$TEMP_REPO_DIR"/*.desktop "$DESKTOP_DIR/" 2>/dev/null || true
|
|
|
|
# Rende eseguibili i file .desktop
|
|
chmod +x "$DESKTOP_DIR"/*.desktop 2>/dev/null || true
|
|
|
|
# Aggiorna il database delle applicazioni
|
|
update-desktop-database "$DESKTOP_DIR" 2>/dev/null || true
|
|
|
|
print_success "File .desktop installati dal repository Gitea"
|
|
|
|
# Lista dei file installati
|
|
INSTALLED_FILES=$(ls "$TEMP_REPO_DIR"/*.desktop 2>/dev/null | xargs -n1 basename)
|
|
if [ ! -z "$INSTALLED_FILES" ]; then
|
|
print_status "File .desktop installati:"
|
|
echo "$INSTALLED_FILES" | sed 's/^/ ✓ /'
|
|
fi
|
|
else
|
|
print_warning "Nessun file .desktop trovato nel repository"
|
|
fi
|
|
|
|
# Pulizia
|
|
rm -rf "$TEMP_REPO_DIR"
|
|
else
|
|
print_error "Impossibile clonare il repository. Verifica le credenziali e la connessione."
|
|
print_status "URL repository: https://gitbat.duckdns.org:44443/alex/desktop-app"
|
|
|
|
# Fallback: prova con cartella locale
|
|
BACKUP_DESKTOP_DIR="./desktop_backup"
|
|
if [ -d "$BACKUP_DESKTOP_DIR" ]; then
|
|
print_status "Utilizzo backup locale dei file .desktop..."
|
|
cp "$BACKUP_DESKTOP_DIR"/*.desktop "$DESKTOP_DIR/" 2>/dev/null || true
|
|
chmod +x "$DESKTOP_DIR"/*.desktop 2>/dev/null || true
|
|
update-desktop-database "$DESKTOP_DIR" 2>/dev/null || true
|
|
print_success "File .desktop ripristinati da backup locale"
|
|
fi
|
|
fi
|
|
|
|
# Aggiunta di ~/.local/bin al PATH per UV e altri strumenti
|
|
if ! grep -q 'export PATH="$HOME/.local/bin:$PATH"' ~/.bashrc; then
|
|
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
|
|
print_success "PATH aggiornato con ~/.local/bin"
|
|
fi
|
|
|
|
# Aggiunta di Cargo bin al PATH
|
|
if ! grep -q 'source ~/.cargo/env' ~/.bashrc; then
|
|
echo 'source ~/.cargo/env' >> ~/.bashrc
|
|
print_success "PATH aggiornato con Cargo"
|
|
fi
|
|
|
|
print_success "=== INSTALLAZIONE COMPLETATA! ==="
|
|
print_status "Applicazioni installate:"
|
|
echo " ✓ Google Chrome"
|
|
echo " ✓ Visual Studio Code con 4 profili configurati:"
|
|
echo " - Default (Git, temi)"
|
|
echo " - Python (Python, Ruff, Flake8, Black, Pylint)"
|
|
echo " - Rust (Rust Analyzer, LLDB, Crates)"
|
|
echo " - Web (TypeScript, Tailwind, Auto-rename, Prettier)"
|
|
echo " ✓ FileZilla"
|
|
echo " ✓ DBeaver"
|
|
echo " ✓ Warp Terminal"
|
|
echo " ✓ Insomnia"
|
|
echo " ✓ MQTTX"
|
|
echo " ✓ FortiClient VPN"
|
|
echo " ✓ Git"
|
|
echo " ✓ Python3"
|
|
echo " ✓ Rust"
|
|
echo " ✓ UV"
|
|
echo " ✓ Ruff"
|
|
echo " ✓ Incus con UI"
|
|
|
|
print_warning "IMPORTANTE:"
|
|
echo "1. Riavvia il sistema o disconnettiti/riconnettiti per applicare tutte le modifiche"
|
|
echo "2. Git è già configurato con le credenziali fornite"
|
|
echo "3. Per Incus, verifica la configurazione con: incus list"
|
|
echo "4. I file .desktop sono stati scaricati dal repository Gitea alex/desktop-app"
|
|
echo "5. FortiClient VPN è installato - configuralo con i dati del tuo server FortiGate"
|
|
|
|
print_status "=== CREDENZIALI GIT CONFIGURATE ==="
|
|
echo "Repository Gitea: https://gitbat.duckdns.org:44443/"
|
|
echo "Username Git globale: $GIT_USERNAME"
|
|
echo "Email Git globale: $GIT_EMAIL"
|
|
echo "Username Gitea: $GITEA_USERNAME"
|
|
echo ""
|
|
|
|
print_status "=== UTILIZZO PROFILI VS CODE ==="
|
|
echo "Per aprire VS Code con un profilo specifico:"
|
|
echo " code --profile \"Default\" /percorso/progetto # Profilo generale"
|
|
echo " code --profile \"Python\" /percorso/progetto # Profilo Python"
|
|
echo " code --profile \"Rust\" /percorso/progetto # Profilo Rust"
|
|
echo " code --profile \"Web\" /percorso/progetto # Profilo Web"
|
|
echo ""
|
|
echo "Puoi anche cambiare profilo dall'interfaccia: File → Preferences → Profiles"
|
|
echo ""
|
|
echo "Per clonare repository da Gitea:"
|
|
echo " git clone https://gitbat.duckdns.org:44443/user/repo.git"
|
|
|
|
print_status "Buon lavoro!"
|