Files
dotfiles/setup.sh
T
2026-05-09 18:04:28 +00:00

79 lines
2.4 KiB
Bash

#!/bin/sh
# --- 1. Konfiguration ---
GITEA_RAW="https://git.ungruhe.info/Tim/dotfiles/raw/branch/main"
echo "🔍 Scanne System-Umgebung..."
# --- 2. Erweiterte System-Erkennung (Inkl. Termux) ---
if [ -d "/data/data/com.termux/files/usr" ]; then
SPECIFIC_ID="termux"
BASE_ID="android"
BIN_PATH="/data/data/com.termux/files/usr/bin"
elif [ -f /etc/os-release ]; then
. /etc/os-release
SPECIFIC_ID=$ID
BASE_ID=$ID_LIKE
BIN_PATH="/usr/bin"
else
SPECIFIC_ID="unknown"
BASE_ID="unknown"
BIN_PATH="/usr/bin"
fi
# --- 3. Pakete installieren ---
echo "📦 Installiere Voraussetzungen für $SPECIFIC_ID..."
# Sudo Logik (Termux braucht kein Sudo)
if command -v sudo >/dev/null 2>&1 && [ "$SPECIFIC_ID" != "termux" ]; then
S="sudo"
else
S=""
fi
case "$SPECIFIC_ID" in
termux)
pkg update && pkg install -y zsh curl git neovim fastfetch eza ncurses-utils ;;
*arch*|*cachyos*)
$S pacman -Syu --needed --noconfirm zsh curl git neovim fastfetch eza shadow ;;
*debian*|*ubuntu*|*trixie*)
$S apt-get update && $S apt-get install -y zsh curl git neovim fastfetch eza ;;
*alpine*)
$S apk add zsh curl git neovim fastfetch eza shadow ncurses-terminfo-base ;;
esac
# --- 4. Verzeichnisse erstellen (Termux-Safe) ---
# In Termux ist $HOME meist /data/data/com.termux/files/home
mkdir -p "$HOME/.config/nvim" "$HOME/.config/fastfetch"
# --- 5. .zshrc mit Fallback laden ---
echo "📥 Lade ZSH-Konfiguration..."
SUCCESS=0
# Suchreihenfolge: spezifische ID -> Basis ID -> default
for TARGET in "$SPECIFIC_ID" "$BASE_ID" "default"; do
if [ -n "$TARGET" ] && [ "$SUCCESS" -eq 0 ]; then
if curl -fsSL "${GITEA_RAW}/.zshrc${TARGET}" -o "$HOME/.zshrc"; then
echo "✅ Erfolg mit .zshrc${TARGET}"
SUCCESS=1
fi
fi
done
# --- 6. Restliche Configs ---
curl -fsSL "${GITEA_RAW}/init.lua" -o "$HOME/.config/nvim/init.lua"
curl -fsSL "${GITEA_RAW}/fastfetch.jsonc" -o "$HOME/.config/fastfetch/fastfetch.jsonc"
# --- 7. Shell-Wechsel ---
# In Termux gibt es kein 'chsh' im klassischen Sinne oder es funktioniert anders
if [ "$SPECIFIC_ID" = "termux" ]; then
# Setzt ZSH als Login-Shell für Termux
chsh -s zsh >/dev/null 2>&1
else
if [ "$SHELL" != "$(command -v zsh)" ]; then
$S chsh -s "$(command -v zsh)" "$(whoami)"
fi
fi
echo "🚀 Setup abgeschlossen! Starte ZSH..."
exec zsh -l