From 2d932f9924cd99c6d42458ece77b91ec2bcd4cb6 Mon Sep 17 00:00:00 2001 From: rene Date: Sat, 7 Mar 2026 15:27:48 +0100 Subject: [PATCH] =?UTF-8?q?Initial=20commit:=20Linux-Setup=20f=C3=BCr=20Ma?= =?UTF-8?q?cBook=20Pro=2013"=20und=2016"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vollautomatisches Post-Install-Setup für Ubuntu 24.04 auf MacBook Pro Late 2013 (13") und Mid 2014 (16" mit Nvidia Optimus). Enthält: - setup.sh: Komplettes Post-Install-Skript (Pakete, Xubuntu, Brave, PrusaSlicer, oh-my-zsh, Claude Code, Dotfiles via Forgejo/Stow, mbpfan, thermald, TLP, WireGuard, Lokalisierung DE) - build-iso.sh: Ubuntu Autoinstall ISO für Ventoy erstellen - user-data/meta-data: cloud-init Autoinstall-Konfiguration - mbpfan-13.conf / mbpfan-16.conf: Modellspezifische Lüftersteuerung - hid_apple.conf / keyboard: Deutsche Mac-Tastaturbelegung + Fn-Tasten - blacklist-nvidia.conf: Optionaler Nvidia/nouveau-Blacklist - temp-watch.sh: CPU-Temperaturüberwachung mit Desktop-Notification Infrastruktur-Abhängigkeiten: - Dotfiles: git.motocamp.de/rene/dotfiles.git (via GNU Stow) - DiskStation 10.47.11.10 (SMTP, IMAP, Synology Drive) - WireGuard-VPN 10.13.13.x ins Heimnetz 10.47.11.0/24 Co-Authored-By: Claude Opus 4.6 --- .claude/settings.local.json | 7 ++ README.md | 56 +++++++++ blacklist-nvidia.conf | 9 ++ build-iso.sh | 92 +++++++++++++++ hid_apple.conf | 3 + keyboard | 4 + mbpfan-13.conf | 9 ++ mbpfan-16.conf | 9 ++ meta-data | 2 + setup.sh | 223 ++++++++++++++++++++++++++++++++++++ temp-watch.sh | 27 +++++ user-data | 53 +++++++++ 12 files changed, 494 insertions(+) create mode 100644 .claude/settings.local.json create mode 100644 README.md create mode 100644 blacklist-nvidia.conf create mode 100644 build-iso.sh create mode 100644 hid_apple.conf create mode 100644 keyboard create mode 100644 mbpfan-13.conf create mode 100644 mbpfan-16.conf create mode 100644 meta-data create mode 100644 setup.sh create mode 100644 temp-watch.sh create mode 100644 user-data diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..ded820a --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,7 @@ +{ + "permissions": { + "allow": [ + "Bash(git:*)" + ] + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..947c999 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# macbook-setup + +Automatisiertes Linux-Setup für MacBook Pro 13" Late 2013 und 16" Mid 2014. + +## Inhalt + +| Datei | Beschreibung | +|-------|-------------| +| `setup.sh` | Vollautomatisches Post-Install-Skript | +| `user-data` | Ubuntu Autoinstall (cloud-init) für ISO-Erstellung | +| `meta-data` | cloud-init Metadaten (erforderlich) | +| `mbpfan-13.conf` | mbpfan-Konfiguration für MBP 13" Late 2013 | +| `mbpfan-16.conf` | mbpfan-Konfiguration für MBP 16" Mid 2014 (Nvidia, aggressiver) | +| `hid_apple.conf` | Fn-Tasten als Standard (fnmode=2) | +| `keyboard` | Tastaturbelegung Deutsch (Macintosh) | +| `blacklist-nvidia.conf` | Nvidia/nouveau blacklisten (optional, für Intel-only Betrieb) | +| `temp-watch.sh` | Temperatur-Überwachung mit Desktop-Notification | +| `build-iso.sh` | ISO-Erstellungs-Skript für Ventoy | + +## Schnellstart + +### Option A: Automatisches Setup nach Minimalinstallation +```bash +curl -fsSL https://git.motocamp.de/rene/macbook-setup/raw/branch/main/setup.sh | bash +``` + +### Option B: Vollautomatische ISO erstellen +```bash +git clone https://git.motocamp.de/rene/macbook-setup.git +cd macbook-setup +./build-iso.sh +# → ubuntu-macbook-autoinstall.iso (für Ventoy) +``` + +## Voraussetzungen + +- WireGuard-Config für das jeweilige MacBook (separat aufbewahren) +- Forgejo-Zugang für Dot-Files-Clone +- Thunderbird-Profil-Backup in Synology Drive + +## Hardware-Besonderheiten + +### MBP 16" Mid 2014 (Intel + Nvidia GT 750M) +- Nvidia Optimus: `prime-select intel` als Standard +- Aggressivere Lüfter-Konfiguration via `mbpfan-16.conf` +- Bei Problemen: `blacklist-nvidia.conf` aktivieren + +### MBP 13" Late 2013 +- Robuster, keine Dual-GPU-Probleme +- Standard `mbpfan-13.conf` reicht aus + +## Abhängigkeiten + +- Netzwerk: `10.47.11.0/24` (via WireGuard `10.13.13.x`) +- DiskStation: `10.47.11.10` (SMTP, IMAP, Synology Drive) +- Dot-Files: `https://git.motocamp.de/rene/dotfiles.git` diff --git a/blacklist-nvidia.conf b/blacklist-nvidia.conf new file mode 100644 index 0000000..aa26801 --- /dev/null +++ b/blacklist-nvidia.conf @@ -0,0 +1,9 @@ +# blacklist-nvidia.conf +# Nur aktivieren wenn Nvidia komplett deaktiviert werden soll (Intel-only Betrieb) +# Kopieren nach /etc/modprobe.d/blacklist-nvidia.conf +# Danach: sudo update-initramfs -u && sudo reboot +blacklist nouveau +blacklist nvidia +blacklist nvidia_drm +blacklist nvidia_modeset +options nouveau modeset=0 diff --git a/build-iso.sh b/build-iso.sh new file mode 100644 index 0000000..32d9c9d --- /dev/null +++ b/build-iso.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# build-iso.sh — Ubuntu 24.04 Autoinstall ISO für Ventoy bauen +# Ausführen auf einem Ubuntu/Debian-System mit Internetzugang +# Ergebnis: ubuntu-macbook-autoinstall.iso (~4-5 GB) + +set -e +UBUNTU_ISO_URL="https://releases.ubuntu.com/24.04/ubuntu-24.04-live-server-amd64.iso" +UBUNTU_ISO="ubuntu-24.04-live-server-amd64.iso" +OUTPUT_ISO="ubuntu-macbook-autoinstall.iso" +WORKDIR="/tmp/iso-build" + +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}"; } + +echo "════════════════════════════════════════════" +echo " macbook-setup ISO Builder" +echo "════════════════════════════════════════════" + +# Abhängigkeiten +echo -e "\n=== Abhängigkeiten prüfen ===" +sudo apt install -y xorriso squashfs-tools genisoimage +ok "Werkzeuge verfügbar" + +# Ubuntu ISO herunterladen (falls nicht vorhanden) +if [[ ! -f "$UBUNTU_ISO" ]]; then + echo -e "\n=== Ubuntu 24.04 ISO herunterladen ===" + wget --show-progress -O "$UBUNTU_ISO" "$UBUNTU_ISO_URL" + ok "ISO heruntergeladen" +else + ok "ISO bereits vorhanden: $UBUNTU_ISO" +fi + +# Arbeitsverzeichnis vorbereiten +echo -e "\n=== ISO entpacken ===" +rm -rf "$WORKDIR" +mkdir -p "$WORKDIR/source" +sudo mount -o loop "$UBUNTU_ISO" /mnt +cp -rT /mnt "$WORKDIR/source" +sudo umount /mnt +chmod -R u+w "$WORKDIR/source" +ok "ISO entpackt nach $WORKDIR/source" + +# autoinstall-Dateien einfügen +echo -e "\n=== Autoinstall-Dateien einbetten ===" +mkdir -p "$WORKDIR/source/autoinstall" +cp user-data "$WORKDIR/source/autoinstall/" +cp meta-data "$WORKDIR/source/autoinstall/" +ok "user-data und meta-data eingefügt" + +# GRUB-Konfiguration: autoinstall-Parameter hinzufügen +echo -e "\n=== GRUB konfigurieren ===" +GRUB_CFG="$WORKDIR/source/boot/grub/grub.cfg" +# Autoinstall-Eintrag am Anfang einfügen +cat > /tmp/grub-autoinstall.cfg <<'EOF' +set default=0 +set timeout=10 + +menuentry "Ubuntu MacBook AutoInstall" { + set gfxpayload=keep + linux /casper/vmlinuz quiet autoinstall ds=nocloud\;s=/cdrom/autoinstall/ --- + initrd /casper/initrd +} + +EOF +cat /tmp/grub-autoinstall.cfg "$GRUB_CFG" > /tmp/grub-merged.cfg +mv /tmp/grub-merged.cfg "$GRUB_CFG" +ok "GRUB konfiguriert (autoinstall als Standard)" + +# ISO neu bauen +echo -e "\n=== ISO bauen ===" +xorriso -as mkisofs \ + -r -V "Ubuntu-24.04-MacBook" \ + -J -joliet-long \ + -b boot/grub/i386-pc/eltorito.img \ + -c boot.catalog \ + -no-emul-boot -boot-load-size 4 -boot-info-table \ + --efi-boot boot/grub/efi.img \ + -efi-boot-part --efi-startup-part --protective-msdos-label \ + "$WORKDIR/source" \ + -o "$OUTPUT_ISO" + +ok "ISO erstellt: $OUTPUT_ISO" +echo "" +echo "Größe: $(du -sh "$OUTPUT_ISO" | cut -f1)" +echo "" +warn "Nächster Schritt: ISO auf Ventoy-Stick kopieren" +echo " cp $OUTPUT_ISO /media/\$USER/Ventoy/" +echo "" +warn "Vor der Installation: user-data anpassen!" +echo " - Passwort-Hash: mkpasswd -m sha-512 DEINPASSWORT" +echo " - Modell: 'setup.sh -- 13' oder 'setup.sh -- 16' in user-data" diff --git a/hid_apple.conf b/hid_apple.conf new file mode 100644 index 0000000..b9fed99 --- /dev/null +++ b/hid_apple.conf @@ -0,0 +1,3 @@ +# Fn-Tasten als Standard (F1-F12 direkt, ohne Fn-Taste) +# Beschriftung auf MacBook-Tastatur stimmt damit überein +options hid_apple fnmode=2 diff --git a/keyboard b/keyboard new file mode 100644 index 0000000..6f02b2c --- /dev/null +++ b/keyboard @@ -0,0 +1,4 @@ +XKBMODEL="macbook79" +XKBLAYOUT="de" +XKBVARIANT="mac" +XKBOPTIONS="lv3:lalt_switch,terminate:ctrl_alt_bksp" diff --git a/mbpfan-13.conf b/mbpfan-13.conf new file mode 100644 index 0000000..9b6257c --- /dev/null +++ b/mbpfan-13.conf @@ -0,0 +1,9 @@ +# mbpfan.conf für MacBook Pro 13" Late 2013 +# Konservativere Einstellungen (kein Nvidia, weniger Hitzeproblem) +[general] +min_fan1_speed = 2000 +max_fan1_speed = 6200 +low_temp = 55 +high_temp = 65 +max_temp = 80 +polling_interval = 3 diff --git a/mbpfan-16.conf b/mbpfan-16.conf new file mode 100644 index 0000000..42ee9b0 --- /dev/null +++ b/mbpfan-16.conf @@ -0,0 +1,9 @@ +# mbpfan.conf für MacBook Pro 16" Mid 2014 +# Aggressivere Einstellungen wegen Intel + Nvidia GT 750M (Optimus) +[general] +min_fan1_speed = 2500 +max_fan1_speed = 6200 +low_temp = 50 +high_temp = 60 +max_temp = 75 +polling_interval = 3 diff --git a/meta-data b/meta-data new file mode 100644 index 0000000..e1ba485 --- /dev/null +++ b/meta-data @@ -0,0 +1,2 @@ +instance-id: macbook-autoinstall +local-hostname: macbook diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..e732f29 --- /dev/null +++ b/setup.sh @@ -0,0 +1,223 @@ +#!/bin/bash +# macbook-setup/setup.sh +# Vollautomatisches Post-Install-Skript für Linux auf MacBook Pro +# Verwendung: curl -fsSL https://git.motocamp.de/rene/macbook-setup/raw/branch/main/setup.sh | bash +# Oder: bash setup.sh [13|16] (Modell optional, wird sonst abgefragt) + +set -e +FORGEJO="https://git.motocamp.de" +DOTFILES_REPO="$FORGEJO/rene/dotfiles.git" +SETUP_REPO="$FORGEJO/rene/macbook-setup.git" +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 + Nvidia)" + read -rp "Modell [13/16]: " MODEL + [[ "$MODEL" != "13" && "$MODEL" != "16" ]] && err "Ungültiges Modell: $MODEL" +fi +ok "Modell: MacBook Pro $MODEL\"" + +# ── Root-Check ─────────────────────────────────────────────────────────── +[[ $EUID -eq 0 ]] && err "Nicht als root ausführen. sudo wird intern verwendet." + +echo "" +echo "════════════════════════════════════════════" +echo " macbook-setup für MBP $MODEL\" startet" +echo "════════════════════════════════════════════" + +# ── 1. System aktualisieren ────────────────────────────────────────────── +echo -e "\n=== 1/12 System aktualisieren ===" +sudo apt update && sudo apt upgrade -y +ok "System aktuell" + +# ── 2. Pakete installieren ─────────────────────────────────────────────── +echo -e "\n=== 2/12 Pakete installieren ===" +sudo 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 \ + libreoffice libreoffice-l10n-de \ + thunderbird thunderbird-locale-de \ + freecad \ + keepassxc \ + htop btop \ + timeshift \ + vlc \ + language-pack-de \ + wngerman \ + bc \ + xfce4-terminal +ok "Pakete installiert" + +# ── 3. Nvidia (nur MBP 16") ────────────────────────────────────────────── +if [[ "$MODEL" == "16" ]]; then + echo -e "\n=== 3/12 Nvidia Optimus (MBP 16\") ===" + sudo apt install -y nvidia-driver-535 nvidia-prime bbswitch-dkms + sudo prime-select intel + ok "Nvidia installiert, Intel als Standard-GPU gesetzt" +else + echo -e "\n=== 3/12 Nvidia (MBP 13\") — übersprungen ===" + ok "Kein Nvidia auf MBP 13\"" +fi + +# ── 4. Brave Browser ───────────────────────────────────────────────────── +echo -e "\n=== 4/12 Brave Browser ===" +sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg \ + https://brave-keyring.s3.brave.com/brave-browser-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] \ +https://brave-releases.s3.brave.com/ stable main" \ + | sudo tee /etc/apt/sources.list.d/brave-browser-release.list +sudo apt update && sudo apt install -y brave-browser +ok "Brave installiert" + +# ── 5. PrusaSlicer ─────────────────────────────────────────────────────── +echo -e "\n=== 5/12 PrusaSlicer AppImage ===" +mkdir -p ~/Applications +PRUSA_URL="https://github.com/prusa3d/PrusaSlicer/releases/download/version_2.8.1/PrusaSlicer-2.8.1+linux-x64-GTK3-202410181354.AppImage" +wget -q --show-progress -O ~/Applications/PrusaSlicer.AppImage "$PRUSA_URL" +chmod +x ~/Applications/PrusaSlicer.AppImage +# Desktop-Eintrag +cat > ~/.local/share/applications/prusaslicer.desktop < /dev/null < /dev/null + +# mbpfan (modellabhängig) +wget -q -O /tmp/mbpfan.conf "$SETUP_RAW/mbpfan-${MODEL}.conf" +sudo cp /tmp/mbpfan.conf /etc/mbpfan.conf + +# Temperatur-Watch-Skript +wget -q -O /tmp/temp-watch.sh "$SETUP_RAW/temp-watch.sh" +sudo cp /tmp/temp-watch.sh /usr/local/bin/temp-watch.sh +sudo chmod +x /usr/local/bin/temp-watch.sh + +# Nvidia blacklist (nur MBP 16", optional) +if [[ "$MODEL" == "16" ]]; then + wget -q -O /tmp/blacklist-nvidia.conf "$SETUP_RAW/blacklist-nvidia.conf" + warn "MBP 16\": blacklist-nvidia.conf liegt in /tmp — nur aktivieren wenn Nvidia nicht gebraucht wird" +fi + +sudo update-initramfs -u +ok "Systemkonfigurationen gesetzt" + +# ── 10. Energieeinstellungen ───────────────────────────────────────────── +echo -e "\n=== 10/12 Energieeinstellungen ===" + +# XFCE Power Manager (Akku) +xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-ac-off -s 0 --create -t int +xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-ac-sleep -s 0 --create -t int +xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/blank-on-ac -s 0 --create -t int +xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-off -s 10 --create -t int +xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-sleep -s 10 --create -t int +xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/blank-on-battery -s 10 --create -t int + +# systemd sleep + logind +sudo tee /etc/systemd/sleep.conf > /dev/null < /dev/null </dev/null || true +sudo systemctl enable --now mbpfan +sudo systemctl enable --now thermald +sudo systemctl enable tlp +ok "mbpfan, thermald, tlp aktiv" + +# ── Zusammenfassung ────────────────────────────────────────────────────── +echo "" +echo "════════════════════════════════════════════" +echo -e " ${GREEN}Setup abgeschlossen!${NC}" +echo "════════════════════════════════════════════" +echo "" +warn "Noch manuell erledigen:" +echo " 1. WireGuard-Config einspielen:" +echo " sudo cp wg0.conf /etc/wireguard/ && sudo systemctl enable --now wg-quick@wg0" +echo " 2. Synology Drive Client installieren (.deb von synology.com)" +echo " 3. Thunderbird starten → Profil aus Synology Drive einbinden" +echo " 4. Brave starten → Synchronisation einrichten" +echo "" +warn "Neustart empfohlen!" +echo " sudo reboot" diff --git a/temp-watch.sh b/temp-watch.sh new file mode 100644 index 0000000..983ff4f --- /dev/null +++ b/temp-watch.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# temp-watch.sh — Temperaturüberwachung mit Desktop-Notification +# Systemd-Service oder XFCE Autostart +# Warnt bei CPU-Temperatur > THRESHOLD Grad Celsius + +THRESHOLD=85 +INTERVAL=30 + +while true; do + TEMP=$(sensors 2>/dev/null | grep -E "Core 0|Package id" | grep -oP '\+\K[0-9.]+' | sort -n | tail -1) + + if [[ -n "$TEMP" ]] && (( $(echo "$TEMP > $THRESHOLD" | bc -l) )); then + # Aktuellen Desktop-User ermitteln + DESK_USER=$(who | grep -m1 '(:0)' | awk '{print $1}') + if [[ -n "$DESK_USER" ]]; then + USER_ID=$(id -u "$DESK_USER") + DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${USER_ID}/bus" \ + sudo -u "$DESK_USER" notify-send \ + -u critical \ + -i dialog-warning \ + "🌡 CPU-Temperatur kritisch" \ + "${TEMP}°C — Lüfter prüfen!\nmbpfan: $(systemctl is-active mbpfan)" + fi + fi + + sleep "$INTERVAL" +done diff --git a/user-data b/user-data new file mode 100644 index 0000000..a9d1d2a --- /dev/null +++ b/user-data @@ -0,0 +1,53 @@ +#cloud-config +autoinstall: + version: 1 + locale: de_DE.UTF-8 + keyboard: + layout: de + variant: mac + identity: + hostname: macbook + username: rene + # Passwort mit `mkpasswd -m sha-512 PASSWORT` generieren und hier ersetzen: + password: "$6$CHANGEME$CHANGEME" + ssh: + install-server: false + storage: + layout: + name: lvm + packages: + - bcmwl-kernel-source + - mbpfan + - thermald + - lm-sensors + - git + - curl + - wget + - zsh + - neovim + - stow + - build-essential + - python3 + - python3-pip + - nodejs + - npm + - wireguard + - wireguard-tools + - libreoffice + - libreoffice-l10n-de + - thunderbird + - thunderbird-locale-de + - language-pack-de + - wngerman + - tlp + - tlp-rdw + - keepassxc + - htop + - btop + - timeshift + - vlc + - bc + late-commands: + # setup.sh aus Forgejo ausführen — Modell als Argument übergeben (13 oder 16) + - curtin in-target --target=/target -- bash -c 'curl -fsSL https://git.motocamp.de/rene/macbook-setup/raw/branch/main/setup.sh | bash -s -- 13' + # Für MBP 16": oben "13" durch "16" ersetzen