diff --git a/README.md b/README.md index 283d91c..779460d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ Automatisiertes Linux-Setup für MacBook Pro 13" Late 2013 und 16" Mid 2014. | Datei | Beschreibung | |-------|-------------| -| `setup.sh` | Vollautomatisches Post-Install-Skript | +| `setup.sh` | Wrapper: ruft setup-base.sh + setup-desktop.sh auf (Option A) | +| `setup-base.sh` | System-Setup: Pakete, Configs, Locale, Services (chroot-sicher) | +| `setup-desktop.sh` | Desktop-Setup: oh-my-zsh, Claude Code, PrusaSlicer, Dotfiles, XFCE | | `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 | diff --git a/setup-base.sh b/setup-base.sh new file mode 100644 index 0000000..230550a --- /dev/null +++ b/setup-base.sh @@ -0,0 +1,162 @@ +#!/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 + Nvidia)" + 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 "════════════════════════════════════════════" + +# ── 1. System aktualisieren ────────────────────────────────────────────── +echo -e "\n=== 1/8 System aktualisieren ===" +apt update && apt upgrade -y +ok "System aktuell" + +# ── 2. Pakete installieren ─────────────────────────────────────────────── +echo -e "\n=== 2/8 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 \ + 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/8 Nvidia Optimus (MBP 16\") ===" + apt install -y nvidia-driver-535 nvidia-prime bbswitch-dkms + prime-select intel + ok "Nvidia installiert, Intel als Standard-GPU gesetzt" +else + echo -e "\n=== 3/8 Nvidia (MBP 13\") — übersprungen ===" + ok "Kein Nvidia auf MBP 13\"" +fi + +# ── 4. Brave Browser ───────────────────────────────────────────────────── +echo -e "\n=== 4/8 Brave Browser ===" +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" \ + | tee /etc/apt/sources.list.d/brave-browser-release.list +apt update && apt install -y brave-browser +ok "Brave installiert" + +# ── 5. Konfigurationsdateien ───────────────────────────────────────────── +echo -e "\n=== 5/8 Systemkonfigurationen ===" + +# Tastaturbelegung +tee /etc/default/keyboard > /dev/null < /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 + +# 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 + +update-initramfs -u +ok "Systemkonfigurationen gesetzt" + +# ── 6. Energieeinstellungen (systemd) ──────────────────────────────────── +echo -e "\n=== 6/8 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" + +# ── 8. Services aktivieren ────────────────────────────────────────────── +echo -e "\n=== 8/8 Services aktivieren ===" +systemctl enable mbpfan +systemctl enable thermald +systemctl enable tlp +# --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 + sensors-detect --auto 2>/dev/null || true + ok "mbpfan, thermald, tlp aktiv (gestartet)" +else + ok "mbpfan, thermald, tlp aktiviert (Start nach Reboot)" +fi + +# ── zsh als Standard-Shell für rene ────────────────────────────────────── +chsh -s /bin/zsh rene 2>/dev/null || true + +echo "" +echo "════════════════════════════════════════════" +echo -e " ${GREEN}setup-base.sh abgeschlossen!${NC}" +echo "════════════════════════════════════════════" diff --git a/setup-desktop.sh b/setup-desktop.sh new file mode 100644 index 0000000..c05bbcd --- /dev/null +++ b/setup-desktop.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# macbook-setup/setup-desktop.sh +# Desktop-Setup: oh-my-zsh, Claude Code, PrusaSlicer, Dotfiles, XFCE-Einstellungen +# Braucht eine laufende Desktop-Session (XFCE) — NICHT in chroot ausführen! +# Verwendung: bash setup-desktop.sh +# Wird automatisch beim ersten Login gestartet (via Autostart) + +set -e +FORGEJO="https://git.motocamp.de" +DOTFILES_REPO="$FORGEJO/rene/dotfiles-rene.git" + +# ── 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; } + +# ── Root-Check ─────────────────────────────────────────────────────────── +[[ $EUID -eq 0 ]] && err "Nicht als root ausführen!" + +echo "" +echo "════════════════════════════════════════════" +echo " setup-desktop.sh startet" +echo "════════════════════════════════════════════" + +# ── 1. oh-my-zsh ──────────────────────────────────────────────────────── +echo -e "\n=== 1/5 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 +ok "oh-my-zsh installiert" + +# ── 2. npm global + Claude Code ───────────────────────────────────────── +echo -e "\n=== 2/5 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" + +# ── 3. PrusaSlicer ────────────────────────────────────────────────────── +echo -e "\n=== 3/5 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" +if [[ ! -f ~/Applications/PrusaSlicer.AppImage ]]; then + wget -q --show-progress -O ~/Applications/PrusaSlicer.AppImage "$PRUSA_URL" + chmod +x ~/Applications/PrusaSlicer.AppImage +fi +mkdir -p ~/.local/share/applications +cat > ~/.local/share/applications/prusaslicer.desktop </dev/null; then + 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 + ok "XFCE Power Manager konfiguriert" +else + warn "xfconf-query nicht gefunden — XFCE Energieeinstellungen übersprungen" +fi + +# ── Autostart entfernen ───────────────────────────────────────────────── +AUTOSTART_FILE="$HOME/.config/autostart/macbook-setup-desktop.desktop" +if [[ -f "$AUTOSTART_FILE" ]]; then + rm "$AUTOSTART_FILE" + ok "Firstboot-Autostart entfernt" +fi + +# ── Zusammenfassung ────────────────────────────────────────────────────── +echo "" +echo "════════════════════════════════════════════" +echo -e " ${GREEN}Desktop-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" diff --git a/setup.sh b/setup.sh index 6182bb8..de86e5c 100644 --- a/setup.sh +++ b/setup.sh @@ -1,21 +1,22 @@ #!/bin/bash # macbook-setup/setup.sh # Vollautomatisches Post-Install-Skript für Linux auf MacBook Pro +# Ruft setup-base.sh (als root) und setup-desktop.sh (als User) auf +# # 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-rene.git" -SETUP_REPO="$FORGEJO/rene/macbook-setup.git" -SETUP_RAW="$FORGEJO/rene/macbook-setup/raw/branch/main" +SETUP_RAW="https://git.motocamp.de/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; } +# ── Root-Check ─────────────────────────────────────────────────────────── +[[ $EUID -eq 0 ]] && err "Nicht als root ausführen. sudo wird intern verwendet." + # ── Modell ermitteln ───────────────────────────────────────────────────── if [[ "$1" == "13" || "$1" == "16" ]]; then MODEL="$1" @@ -27,197 +28,25 @@ else 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 " macbook-setup für MBP $MODEL\" (komplett)" echo "════════════════════════════════════════════" -# ── 1. System aktualisieren ────────────────────────────────────────────── -echo -e "\n=== 1/12 System aktualisieren ===" -sudo apt update && sudo apt upgrade -y -ok "System aktuell" +# ── Phase 1: System-Setup (als root) ──────────────────────────────────── +echo -e "\n>>> Phase 1: setup-base.sh (System)" +curl -fsSL "$SETUP_RAW/setup-base.sh" | sudo bash -s -- "$MODEL" +ok "Phase 1 abgeschlossen" -# ── 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" +# ── Phase 2: Desktop-Setup (als User) ─────────────────────────────────── +echo -e "\n>>> Phase 2: setup-desktop.sh (Desktop)" +curl -fsSL "$SETUP_RAW/setup-desktop.sh" | bash +ok "Phase 2 abgeschlossen" -# ── 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 -e " ${GREEN}Komplett-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" +echo "Neustart empfohlen: sudo reboot" diff --git a/user-data b/user-data index a9d1d2a..f7c9329 100644 --- a/user-data +++ b/user-data @@ -15,39 +15,18 @@ autoinstall: 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 + # System-Setup in chroot (Pakete, Configs, Locale, Services) + - curtin in-target --target=/target -- bash -c 'curl -fsSL https://git.motocamp.de/rene/macbook-setup/raw/branch/main/setup-base.sh | bash -s -- 13' + # Desktop-Setup als Firstboot-Autostart einrichten + - curtin in-target --target=/target -- mkdir -p /home/rene/.config/autostart + - curtin in-target --target=/target -- bash -c 'cat > /home/rene/.config/autostart/macbook-setup-desktop.desktop <&1 | tee /tmp/setup-desktop.log; exec xfce4-terminal -e \"bash -c less /tmp/setup-desktop.log\"" +Hidden=false +X-GNOME-Autostart-enabled=true +AUTOSTART' + - curtin in-target --target=/target -- chown -R 1000:1000 /home/rene/.config + # Fuer MBP 16": oben "13" durch "16" ersetzen