scripte/client_install_programme_ub...

248 lines
7.4 KiB
Bash

#!/bin/bash
# ================================
# Skript zur Konfiguration von Ubuntu 24.04 (Noble)
# ================================
# Farben
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # Keine Farbe
# ================================
# KONFIGURATION & VARIABLEN
# ================================
# ecoDMS Repository für Ubuntu 24.04 (Noble)
ECODMS_REPO="deb http://www.ecodms.de/ecodms_250264/noble /"
ECODMS_LIST="/etc/apt/sources.list.d/ecodms.list"
DOWNLOAD_DIR="$HOME/deb_packages"
APT_PACKAGES=(
"vlc"
"thunderbird"
"remmina"
"okular"
"libreoffice"
"gimp"
"nextcloud-desktop"
"gnucash"
"chromium-browser" # Bei Ubuntu heißt das Paket oft chromium-browser (oder ist ein Snap transition package)
"curl"
"ttf-mscorefonts-installer"
"ecodmsclient"
"ecodmsprinter"
"wine64"
"terminator"
"gedit"
"network-manager"
"software-properties-common" # Für add-apt-repository
)
SNAP_PACKAGES=(
"spotify"
"bitwarden"
"whatsapp-linux-app"
"notes"
"chatgpt-desktop"
"bw"
)
FLATPAK_PACKAGES=()
# ================================
# FUNKTIONEN
# ================================
# 1. Quellenliste aktualisieren & ecoDMS
update_sources() {
echo -e "${GREEN}System wird aktualisiert...${NC}"
# Standard-Updates
sudo apt update && sudo apt upgrade -y
echo -e "${GREEN}Füge ecoDMS Repository (Noble) hinzu...${NC}"
# GPG Key holen
wget -qO - http://www.ecodms.de/gpg/ecodms.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/ecodms.gpg
# Repo Datei erstellen
echo "$ECODMS_REPO" | sudo tee "$ECODMS_LIST" > /dev/null
if [[ $? -ne 0 ]]; then
echo -e "${RED}Fehler beim Hinzufügen des ecoDMS Repositories.${NC}"
exit 1
fi
sudo apt update
}
# 2. APT Pakete installieren
install_apt_packages() {
echo -e "${GREEN}Installiere APT-Pakete...${NC}"
for PACKAGE in "${APT_PACKAGES[@]}"; do
# Check ob installiert
if dpkg -l | grep -q "^ii $PACKAGE "; then
echo -e "${GREEN}$PACKAGE ist bereits installiert.${NC}"
else
sudo apt install -y "$PACKAGE" || echo -e "${RED}Fehler bei $PACKAGE (evtl. existiert es nur als Snap?).${NC}"
fi
done
}
# 3. Snap Pakete installieren
install_snap_packages() {
# Snap ist bei Ubuntu Standard, aber sicherheitshalber prüfen
if ! command -v snap &> /dev/null; then
echo -e "${GREEN}Snap wird installiert...${NC}"
sudo apt install -y snapd
fi
echo -e "${GREEN}Installiere Snap-Pakete...${NC}"
for SNAP in "${SNAP_PACKAGES[@]}"; do
sudo snap install "$SNAP" || sudo snap install "$SNAP" --classic
done
}
# 4. Flatpak installieren
install_flatpak_packages() {
if ! command -v flatpak &> /dev/null; then
echo -e "${GREEN}Flatpak wird installiert...${NC}"
sudo apt install -y flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
fi
}
# 5. DEB Pakete installieren
install_deb_packages() {
echo -e "${GREEN}Lade zusätzliche .deb-Pakete herunter...${NC}"
mkdir -p "$DOWNLOAD_DIR"
declare -A DEB_URLS=(
["shadow-amd64.deb"]="https://update.shadow.tech/launcher/prod/linux/x86_64/shadow-amd64.deb"
["nomachine.deb"]="https://web9001.nomachine.com/download/9.3/Linux/nomachine_9.3.7_1_amd64.deb"
["xpipe.deb"]="https://github.com/xpipe-io/xpipe/releases/latest/download/xpipe-installer-linux-x86_64.deb"
["rustdesk.deb"]="https://github.com/rustdesk/rustdesk/releases/download/1.4.4/rustdesk-1.4.4-x86_64.deb"
)
for FILE in "${!DEB_URLS[@]}"; do
wget -O "$DOWNLOAD_DIR/$FILE" "${DEB_URLS[$FILE]}" || echo -e "${RED}Fehler bei Download von $FILE.${NC}"
done
echo -e "${GREEN}Installiere .deb-Pakete...${NC}"
for DEB_FILE in "$DOWNLOAD_DIR"/*.deb; do
sudo apt install -y "$DEB_FILE" || sudo apt --fix-broken install -y
done
}
# 6. Netzwerk konfigurieren (NetworkManager)
configure_network() {
echo -e "${YELLOW}=== Netzwerkkonfiguration ===${NC}"
# Aktives Interface finden
INTERFACE=$(ip -o -4 route show to default | awk '{print $5}' | head -n1)
if [ -z "$INTERFACE" ]; then
echo -e "${RED}Kein aktives Netzwerk-Interface gefunden! Überspringe Netzwerkkonfiguration.${NC}"
return
fi
echo -e "Aktives Interface erkannt: ${GREEN}$INTERFACE${NC}"
# Verbindungsprofil ermitteln
CON_NAME=$(nmcli -t -f NAME,DEVICE connection show --active | grep ":$INTERFACE" | cut -d: -f1 | head -n1)
if [ -z "$CON_NAME" ]; then
echo -e "${RED}Kein NetworkManager-Profil für $INTERFACE gefunden.${NC}"
return
fi
echo -e "Bearbeite Verbindung: ${GREEN}$CON_NAME${NC}"
# Eingabe der letzten Ziffer
while true; do
read -p "Bitte die letzte Zahl der IP-Adresse eingeben (192.168.176.XXX): " IP_SUFFIX
if [[ "$IP_SUFFIX" =~ ^[0-9]+$ ]] && [ "$IP_SUFFIX" -ge 1 ] && [ "$IP_SUFFIX" -le 254 ]; then
break
else
echo -e "${RED}Ungültige Eingabe. Bitte eine Zahl zwischen 1 und 254 eingeben.${NC}"
fi
done
NEW_IP="192.168.176.$IP_SUFFIX"
GATEWAY="192.168.176.1"
DNS="192.168.176.101 192.168.174.101 1.1.1.1"
echo -e "${GREEN}Setze IP auf $NEW_IP...${NC}"
# Konfiguration anwenden
sudo nmcli con mod "$CON_NAME" \
ipv4.addresses "$NEW_IP/24" \
ipv4.gateway "$GATEWAY" \
ipv4.dns "$DNS" \
ipv4.method manual
echo -e "${GREEN}Netzwerkeinstellungen gespeichert.${NC}"
echo -e "${YELLOW}ACHTUNG: Die neuen Einstellungen werden erst nach einem Neustart der Verbindung aktiv.${NC}"
read -p "Soll die Verbindung jetzt neu gestartet werden? (j/n): " RESTART_NET
if [[ "$RESTART_NET" =~ ^[jJ]$ ]]; then
sudo nmcli con up "$CON_NAME"
fi
}
# 7. Univention Domain Join installieren (Ubuntu PPA Methode)
install_univention_join() {
echo -e "${YELLOW}=== Univention Domain Join Installation ===${NC}"
echo -e "${GREEN}Füge Univention PPA hinzu...${NC}"
# -y flag akzeptiert automatisch die Bestätigung
sudo add-apt-repository -y ppa:univention-dev/ppa
echo -e "${GREEN}Aktualisiere Paketquellen...${NC}"
sudo apt-get update
echo -e "${GREEN}Installiere univention-domain-join...${NC}"
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y univention-domain-join
if [ $? -eq 0 ]; then
echo -e "${GREEN}Univention Domain Join erfolgreich installiert.${NC}"
else
echo -e "${RED}Fehler bei der Installation von Univention Domain Join.${NC}"
fi
}
# 8. Autofs & Shared Dir
setup_system_extras() {
echo -e "${GREEN}Richte autofs ein...${NC}"
sudo apt install -y autofs
if ! grep -q "/net /etc/auto.net" /etc/auto.master; then
echo "/net /etc/auto.net --timeout=600" | sudo tee -a /etc/auto.master
fi
systemctl restart autofs
systemctl enable autofs
SHARED_DIR="/home/shared"
if [ ! -d "$SHARED_DIR" ]; then
sudo mkdir -p "$SHARED_DIR"
sudo chmod 1777 "$SHARED_DIR"
fi
}
# ================================
# HAUPTABLAUF
# ================================
update_sources
install_apt_packages
install_snap_packages
install_flatpak_packages
install_deb_packages
setup_system_extras
# Interaktive Teile am Ende
configure_network
install_univention_join
echo -e "${GREEN}Skript vollständig abgeschlossen.${NC}"