Initial commit: Linux-Setup für MacBook Pro 13" und 16"

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
This commit is contained in:
rene 2026-03-07 15:27:48 +01:00
commit 722bd849f9
12 changed files with 494 additions and 0 deletions

View file

@ -0,0 +1,7 @@
{
"permissions": {
"allow": [
"Bash(git:*)"
]
}
}

56
README.md Normal file
View file

@ -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`

9
blacklist-nvidia.conf Normal file
View file

@ -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

92
build-iso.sh Normal file
View file

@ -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"

3
hid_apple.conf Normal file
View file

@ -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

4
keyboard Normal file
View file

@ -0,0 +1,4 @@
XKBMODEL="macbook79"
XKBLAYOUT="de"
XKBVARIANT="mac"
XKBOPTIONS="lv3:lalt_switch,terminate:ctrl_alt_bksp"

9
mbpfan-13.conf Normal file
View file

@ -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

9
mbpfan-16.conf Normal file
View file

@ -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

2
meta-data Normal file
View file

@ -0,0 +1,2 @@
instance-id: macbook-autoinstall
local-hostname: macbook

223
setup.sh Normal file
View file

@ -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 <<EOF
[Desktop Entry]
Name=PrusaSlicer
Exec=$HOME/Applications/PrusaSlicer.AppImage
Icon=prusaslicer
Type=Application
Categories=Graphics;
EOF
ok "PrusaSlicer installiert"
# ── 6. oh-my-zsh + zsh als Standard-Shell ────────────────────────────────
echo -e "\n=== 6/12 oh-my-zsh ==="
if [[ ! -d ~/.oh-my-zsh ]]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
sudo chsh -s "$(which zsh)" "$USER"
ok "oh-my-zsh installiert, zsh als Standard-Shell"
# ── 7. npm global + Claude Code ──────────────────────────────────────────
echo -e "\n=== 7/12 Claude Code ==="
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH="$HOME/.npm-global/bin:$PATH"
npm install -g @anthropic-ai/claude-code
ok "Claude Code installiert"
# ── 8. Dot-Files ─────────────────────────────────────────────────────────
echo -e "\n=== 8/12 Dot-Files ==="
if [[ ! -d ~/dotfiles ]]; then
git clone "$DOTFILES_REPO" ~/dotfiles
fi
cd ~/dotfiles
# Vorhandene stow-Pakete erkennen und einspielen
for pkg in zsh nvim git ssh; do
[[ -d "$pkg" ]] && stow "$pkg" && ok "Dot-Files: $pkg"
done
cd ~
# ── 9. Konfigurationsdateien aus Setup-Repo ──────────────────────────────
echo -e "\n=== 9/12 Systemkonfigurationen ==="
# Tastaturbelegung
sudo tee /etc/default/keyboard > /dev/null <<EOF
XKBMODEL="macbook79"
XKBLAYOUT="de"
XKBVARIANT="mac"
XKBOPTIONS="lv3:lalt_switch,terminate:ctrl_alt_bksp"
EOF
# Fn-Tasten
echo 'options hid_apple fnmode=2' | sudo tee /etc/modprobe.d/hid_apple.conf > /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 <<EOF
[Sleep]
HibernateDelaySec=1800
EOF
sudo tee -a /etc/systemd/logind.conf > /dev/null <<EOF
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=ignore
EOF
ok "Energieeinstellungen gesetzt"
# ── 11. Lokalisierung ────────────────────────────────────────────────────
echo -e "\n=== 11/12 Lokalisierung ==="
sudo locale-gen de_DE.UTF-8
sudo update-locale LANG=de_DE.UTF-8 LC_ALL=de_DE.UTF-8
sudo timedatectl set-timezone Europe/Berlin
ok "Lokalisierung: Deutsch / Berlin"
# ── 12. Services aktivieren ──────────────────────────────────────────────
echo -e "\n=== 12/12 Services aktivieren ==="
sudo sensors-detect --auto 2>/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"

27
temp-watch.sh Normal file
View file

@ -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

53
user-data Normal file
View file

@ -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