#!/bin/bash # macbook-setup/setup-base-asahi.sh # Basis-Setup fuer Asahi Linux (Fedora Remix) auf Apple Silicon M1 # Fokus: Terminal-Umgebung (zsh, Tools, Screensaver) # System-spezifisches (HiDPI, Energie) wird vor Ort gemacht # Verwendung: sudo bash setup-base-asahi.sh # Kann mehrfach ausgefuehrt werden (idempotent) # ── Farben ────────────────────────────────────────────────────────────── RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' ok() { echo -e "${GREEN}[OK] $*${NC}"; } warn() { echo -e "${YELLOW}[!!] $*${NC}"; } fail() { echo -e "${RED}[FAIL] $*${NC}"; } # ── Root-Check ───────────────────────────────────────────────────────── [[ $EUID -ne 0 ]] && { fail "Bitte als root ausfuehren (sudo)"; exit 1; } echo "" echo "============================================" echo " setup-base-asahi.sh fuer M1 (Asahi Linux)" echo " Terminal-Grundsetup" echo "============================================" # ── 1. sudoers ─────────────────────────────────────────────────────────── echo -e "\n=== 1/8 sudoers ===" cat > /etc/sudoers <<'SUDOEOF' Defaults env_reset Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" root ALL=(ALL:ALL) ALL %wheel ALL=(ALL:ALL) ALL @includedir /etc/sudoers.d SUDOEOF chmod 440 /etc/sudoers echo "rene ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/rene chmod 440 /etc/sudoers.d/rene ok "sudoers: Linux-Standard + NOPASSWD fuer rene" # ── 2. Locale & Timezone ──────────────────────────────────────────────── echo -e "\n=== 2/8 Locale & Timezone ===" dnf install -y glibc-langpack-de 2>/dev/null || true localectl set-locale LANG=de_DE.UTF-8 timedatectl set-timezone Europe/Berlin 2>/dev/null || true ok "Locale: de_DE.UTF-8, Timezone: Europe/Berlin" # ── 3. Sleep verhindern waehrend Installation ─────────────────────────── echo -e "\n=== 3/8 Sleep verhindern ===" systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target 2>/dev/null || true ok "Sleep/Suspend deaktiviert (fuer Installation)" # ── 4. System aktualisieren ───────────────────────────────────────────── echo -e "\n=== 4/8 System aktualisieren ===" dnf upgrade -y || warn "dnf upgrade hatte Probleme" ok "System aktuell" # ── 5. Pakete installieren ────────────────────────────────────────────── echo -e "\n=== 5/8 Pakete installieren ===" # Basis-Tools dnf install -y \ git curl wget \ zsh neovim micro \ python3 python3-pip pipx \ nodejs npm \ openssh-server \ bc \ || warn "Einige Basis-Pakete konnten nicht installiert werden" # Terminal-Tools dnf install -y \ bat eza fd-find fzf ripgrep tldr ncdu duf \ zoxide \ htop btop \ fastfetch \ || warn "Einige Terminal-Tools konnten nicht installiert werden" # Spass-Tools dnf install -y \ cowsay fortune-mod \ cmatrix \ perl-Curses \ || warn "Einige Spass-Tools konnten nicht installiert werden" ok "Pakete installiert" # asciiquarium (Perl-basiert, nicht in Fedora-Repos) echo "" perl -MTerm::Animation -e1 2>/dev/null || cpan -T Term::Animation if ! command -v asciiquarium &>/dev/null; then curl -fsSL https://robobunny.com/projects/asciiquarium/asciiquarium_1.1.tar.gz -o /tmp/asciiquarium.tar.gz \ && tar xzf /tmp/asciiquarium.tar.gz -C /tmp \ && cp /tmp/asciiquarium_1.1/asciiquarium /usr/local/bin/ \ && chmod +x /usr/local/bin/asciiquarium \ && ok "asciiquarium installiert" \ || warn "asciiquarium uebersprungen" # Patch: beliebige Taste beendet asciiquarium (statt nur 'q') if [ -f /usr/local/bin/asciiquarium ]; then sed -i '/\$in eq .q.*quit/d' /usr/local/bin/asciiquarium sed -i "s/elsif( \$in eq 'r'/if ( \$in eq 'r'/" /usr/local/bin/asciiquarium sed -i "/\$in eq 'p'.*paused/a\\\t\t\telsif( \$in ne ERR ) { quit(); } # Any key exits" /usr/local/bin/asciiquarium fi rm -rf /tmp/asciiquarium* fi # ── 6. WireGuard VPN ────────────────────────────────────────────────────── echo -e "\n=== 6/8 WireGuard VPN ===" dnf install -y wireguard-tools 2>/dev/null || true if [[ -f /etc/wireguard/m1.conf ]] || nmcli connection show m1 &>/dev/null; then ok "WireGuard m1 bereits konfiguriert" else warn "WireGuard: m1.conf nach /etc/wireguard/ kopieren, dann: nmcli connection import type wireguard file /etc/wireguard/m1.conf" fi # ── 7. /etc/hosts ─────────────────────────────────────────────────────── echo -e "\n=== 7/8 /etc/hosts ===" for entry in "10.47.11.10 dsm.motocamp.de" "10.47.11.23 git.motocamp.de"; do host="${entry##* }" if ! grep -q "$host" /etc/hosts; then echo "$entry" >> /etc/hosts ok "/etc/hosts: $host" else ok "/etc/hosts: $host (bereits vorhanden)" fi done # ── 8. Services & Shell ───────────────────────────────────────────────── echo -e "\n=== 8/8 Services & Shell ===" systemctl enable sshd 2>/dev/null || true systemctl start sshd 2>/dev/null || true # zsh als Standard-Shell chsh -s /bin/zsh rene 2>/dev/null || true ok "sshd aktiviert, zsh als Standard-Shell" # Sleep wieder erlauben systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target 2>/dev/null || true # ── Zusammenfassung ────────────────────────────────────────────────────── echo "" echo "============================================" echo -e " ${GREEN}Terminal-Grundsetup abgeschlossen!${NC}" echo "============================================" echo "" echo "Naechste Schritte:" echo " 1. Ausloggen und als rene mit zsh neu einloggen" echo " 2. setup-desktop-asahi.sh ausfuehren (oh-my-zsh, Dotfiles, p10k)" echo " 3. WireGuard: m1.conf einrichten (falls noch nicht importiert)"