#!/bin/bash # macbook-setup/setup-base.sh # System-Setup: Pakete, Konfiguration, Locale, Services # Funktioniert in chroot (Autoinstall late-commands) UND standalone # Verwendung: sudo bash setup-base.sh [13|16] set -e FORGEJO="https://git.motocamp.de" SETUP_RAW="$FORGEJO/rene/macbook-setup/raw/branch/main" # ── Farben ────────────────────────────────────────────────────────────── RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' ok() { echo -e "${GREEN}✓ $*${NC}"; } warn() { echo -e "${YELLOW}⚠ $*${NC}"; } err() { echo -e "${RED}✗ $*${NC}"; exit 1; } # ── Modell ermitteln ───────────────────────────────────────────────────── if [[ "$1" == "13" || "$1" == "16" ]]; then MODEL="$1" else echo "" echo "Welches MacBook Pro?" echo " 13 = MBP 13\" Late 2013" echo " 16 = MBP 16\" Mid 2014 (Intel + AMD Radeon)" read -rp "Modell [13/16]: " MODEL [[ "$MODEL" != "13" && "$MODEL" != "16" ]] && err "Ungültiges Modell: $MODEL" fi ok "Modell: MacBook Pro $MODEL\"" echo "" echo "════════════════════════════════════════════" echo " setup-base.sh für MBP $MODEL\" startet" echo "════════════════════════════════════════════" # ── 0. Sleep/Suspend verhindern während Installation ───────────────────── echo -e "\n=== 0/10 Sleep verhindern ===" systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target 2>/dev/null || true ok "Sleep/Suspend deaktiviert (für Installation)" # ── 1. System aktualisieren ────────────────────────────────────────────── echo -e "\n=== 1/10 System aktualisieren ===" apt update && apt upgrade -y ok "System aktuell" # ── 2. Pakete installieren ─────────────────────────────────────────────── echo -e "\n=== 2/10 Pakete installieren ===" apt install -y \ xubuntu-desktop \ bcmwl-kernel-source \ mbpfan thermald \ lm-sensors xfce4-sensors-plugin \ tlp tlp-rdw \ git curl wget stow \ zsh neovim \ build-essential \ python3 python3-pip python3-venv \ nodejs npm \ wireguard wireguard-tools \ openssh-server \ libheif-examples imagemagick \ pipx \ zoxide \ micro \ libreoffice libreoffice-l10n-de \ thunderbird thunderbird-locale-de \ keepassxc \ htop btop \ timeshift \ vlc \ language-pack-de \ wngerman \ bc \ xfce4-terminal ok "Pakete installiert (apt)" # FreeCAD via Snap (nicht in Ubuntu 24.04 Repos verfügbar) snap install freecad 2>/dev/null || warn "FreeCAD Snap übersprungen (chroot)" # ── 3. GPU-Konfiguration ──────────────────────────────────────────────── if [[ "$MODEL" == "16" ]]; then echo -e "\n=== 3/10 AMD Radeon blacklisten (MBP 16\") ===" # MBP 15" Mid 2014 hat Intel HD 5200 + AMD Radeon R9 M370X # Radeon verursacht Grafikartefakte — nur Intel-GPU nutzen cat > /etc/modprobe.d/blacklist-radeon.conf < /dev/null </dev/null || true # Fn-Tasten + ISO-Layout-Fix (iso_layout=0 verhindert ^/< Vertauschung) echo 'options hid_apple fnmode=2 iso_layout=0' | tee /etc/modprobe.d/hid_apple.conf > /dev/null # mbpfan (modellabhängig) wget -q -O /tmp/mbpfan.conf "$SETUP_RAW/mbpfan-${MODEL}.conf" cp /tmp/mbpfan.conf /etc/mbpfan.conf # Temperatur-Watch-Skript wget -q -O /usr/local/bin/temp-watch.sh "$SETUP_RAW/temp-watch.sh" chmod +x /usr/local/bin/temp-watch.sh update-initramfs -u ok "Systemkonfigurationen gesetzt" # ── 6. XFCE-Konfiguration (MBP 16": Compositor aus, Display-Skalierung) ─ if [[ "$MODEL" == "16" ]]; then echo -e "\n=== 6/10 XFCE-Konfiguration (MBP 16\") ===" XFCE_XML_DIR="/home/rene/.config/xfce4/xfconf/xfce-perchannel-xml" mkdir -p "$XFCE_XML_DIR" # Compositor deaktivieren (verursacht Probleme ohne GPU-Beschleunigung) cat > "$XFCE_XML_DIR/xfwm4.xml" < XFEOF # Display-Skalierung für Retina (2x, DPI 168) cat > "$XFCE_XML_DIR/xsettings.xml" < XSEOF # xfce4-display-settings deaktivieren (öffnet sich sonst in Endlosschleife) dpkg-divert --local --rename --divert /usr/bin/xfce4-display-settings.real /usr/bin/xfce4-display-settings ln -sf /usr/bin/true /usr/bin/xfce4-display-settings chown -R 1000:1000 /home/rene/.config/xfce4 ok "XFCE: Compositor aus, Retina-Skalierung, Display-Settings deaktiviert" else echo -e "\n=== 6/10 XFCE-Konfiguration — Standard (MBP 13\") ===" fi # ── 7. Netzwerk: NetworkManager statt netplan ───────────────────────────── echo -e "\n=== 7/10 Netzwerk ===" cat > /etc/netplan/01-network-manager.yaml </dev/null || true systemctl enable NetworkManager-wait-online.service 2>/dev/null || true ok "NetworkManager als Netzwerk-Renderer" # ── 8. Energieeinstellungen (systemd) ──────────────────────────────────── echo -e "\n=== 8/10 Energieeinstellungen ===" tee /etc/systemd/sleep.conf > /dev/null < /dev/null </dev/null || ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime ok "Lokalisierung: Deutsch / Berlin" # ── 10. Services aktivieren ────────────────────────────────────────────── echo -e "\n=== 10/10 Services aktivieren ===" systemctl enable mbpfan systemctl enable thermald systemctl enable tlp systemctl enable ssh # --now nur wenn nicht in chroot if [[ "$(stat -c %d:%i /)" == "$(stat -c %d:%i /proc/1/root/.)" ]] 2>/dev/null; then systemctl start mbpfan systemctl start thermald systemctl start ssh sensors-detect --auto 2>/dev/null || true ok "mbpfan, thermald, tlp, ssh aktiv (gestartet)" else ok "mbpfan, thermald, tlp, ssh aktiviert (Start nach Reboot)" fi # ── cloud-init deaktivieren (kein Cloud-Provider, blockiert sonst den Boot) ── if command -v cloud-init &>/dev/null; then touch /etc/cloud/cloud-init.disabled ok "cloud-init deaktiviert" fi # ── zsh als Standard-Shell für rene ────────────────────────────────────── chsh -s /bin/zsh rene 2>/dev/null || true # ── Sleep wieder erlauben ──────────────────────────────────────────────── systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target 2>/dev/null || true echo "" echo "════════════════════════════════════════════" echo -e " ${GREEN}setup-base.sh abgeschlossen!${NC}" echo "════════════════════════════════════════════"