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

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"