283 lines
10 KiB
Bash
283 lines
10 KiB
Bash
#!/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
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
|
|
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 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
|
|
check_command "Visual Studio Code"
|
|
|
|
# Installazione estensioni VS Code
|
|
print_status "Installazione estensioni VS Code..."
|
|
# Python
|
|
code --install-extension ms-python.python
|
|
code --install-extension ms-python.flake8
|
|
code --install-extension ms-python.python-tools
|
|
code --install-extension ms-python.vscode-pylance
|
|
code --install-extension ms-python.vscode-pyright
|
|
code --install-extension ms-python.debugpy
|
|
# Rust
|
|
code --install-extension rust-lang.rust-analyzer
|
|
code --install-extension formulahendry.code-runner
|
|
code --install-extension vadimcn.vscode-lldb
|
|
code --install-extension fill-labs.dependi
|
|
code --install-extension usernamehw.errorlens
|
|
code --install-extension tamasfe.even-better-toml
|
|
# Git
|
|
code --install-extension ms-vscode.vscode-git
|
|
code --install-extension charliermarsh.ruff
|
|
code --install-extension google.geminicodeassist
|
|
print_success "Estensioni VS Code installate"
|
|
|
|
# === 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
|
|
echo "deb [signed-by=/usr/share/keyrings/dbeaver.gpg] https://dbeaver.io/debs/dbeaver-ce /" | sudo tee /etc/apt/sources.list.d/dbeaver.list
|
|
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
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/warp.gpg] https://releases.warp.dev/linux/deb stable main" | sudo tee /etc/apt/sources.list.d/warp.list
|
|
sudo apt update
|
|
sudo apt install -y warp-terminal
|
|
check_command "Warp Terminal"
|
|
|
|
# === INSOMNIA ===
|
|
print_status "Installazione Insomnia..."
|
|
curl -1sLf 'https://packages.konghq.com/public/insomnia/gpg.DE2A7741A397C129.key' | sudo gpg --dearmor -o /usr/share/keyrings/insomnia.gpg
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/insomnia.gpg] https://packages.konghq.com/public/insomnia/deb/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/insomnia.list
|
|
sudo apt update
|
|
sudo apt install -y insomnia
|
|
check_command "Insomnia"
|
|
|
|
# === MQTTX ===
|
|
print_status "Installazione MQTTX..."
|
|
MQTTX_VERSION=$(curl -s https://api.github.com/repos/emqx/MQTTX/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's/v//')
|
|
wget -O /tmp/mqttx.deb "https://github.com/emqx/MQTTX/releases/download/v${MQTTX_VERSION}/MQTTX-${MQTTX_VERSION}.deb"
|
|
sudo dpkg -i /tmp/mqttx.deb
|
|
sudo apt-get install -f -y # Risolve eventuali dipendenze mancanti
|
|
rm /tmp/mqttx.deb
|
|
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 e pip
|
|
sudo apt install -y python3 python3-pip
|
|
check_command "Python3 e pip"
|
|
|
|
# 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
|
|
echo "deb [signed-by=/etc/apt/keyrings/zabbly.gpg] https://pkgs.zabbly.com/incus/stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/zabbly-incus-stable.list
|
|
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 --minimal
|
|
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 estensioni Python, Rust, Git, UV, Ruff)"
|
|
echo " ✓ FileZilla"
|
|
echo " ✓ DBeaver"
|
|
echo " ✓ Warp Terminal"
|
|
echo " ✓ Insomnia"
|
|
echo " ✓ MQTTX"
|
|
echo " ✓ Git"
|
|
echo " ✓ Python3 e pip"
|
|
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"
|
|
|
|
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 ""
|
|
echo "Per clonare repository da Gitea:"
|
|
echo " git clone https://gitbat.duckdns.org:44443/user/repo.git"
|
|
|
|
print_status "Buon lavoro!" |