Created
February 2, 2026 15:32
-
-
Save sayore/b813153931acad69032335b93de1021e to your computer and use it in GitHub Desktop.
install.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # 🥧 GitPi Ultimate Bootstrap | |
| # Features: State-Management, Interactive Install, Auto-Auth | |
| # --- CONFIG --- | |
| PI_USER="git" | |
| PI_HOST="meow" # <-- DEIN HOSTNAME | |
| REPO_NAME="zsh" # <-- DEIN REPO | |
| TARGET_DIR="$HOME/.config/zsh" | |
| STATE_FILE="$HOME/.gitpi_bootstrap_state" | |
| # Farben | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| RED='\033[0;31m' | |
| BLUE='\033[0;34m' | |
| NC='\033[0m' # No Color | |
| # --- HELPER FUNCTIONS --- | |
| # Lädt Status (Ignorierte Pakete) | |
| load_state() { | |
| if [ ! -f "$STATE_FILE" ]; then touch "$STATE_FILE"; fi | |
| } | |
| # Speichert Ignore-Status | |
| set_ignore() { | |
| echo "$1=IGNORE" >> "$STATE_FILE" | |
| } | |
| # Prüft ob ignoriert | |
| is_ignored() { | |
| grep -q "^$1=IGNORE" "$STATE_FILE" | |
| } | |
| # Der Herzschlag des Scripts: Der Installer-Manager | |
| ask_install() { | |
| NAME=$1 # Name für Anzeige (z.B. "Visual Studio Code") | |
| CMD_CHECK=$2 # Befehl zum Prüfen (z.B. "code-insiders") | |
| INSTALL_CMD=$3 # Funktion/Befehl zum Installieren | |
| echo -n "📦 $NAME: " | |
| # 1. Ist es schon installiert? | |
| if command -v "$CMD_CHECK" >/dev/null 2>&1; then | |
| echo -e "${GREEN}Bereits installiert.${NC}" | |
| echo -n " Möchtest du es updaten/reinstallieren? [y/N] " | |
| read -r choice | |
| case "$choice" in | |
| y|Y) | |
| echo -e " ${BLUE}Starte Re-Install...${NC}" | |
| eval "$INSTALL_CMD" | |
| ;; | |
| *) | |
| echo " Skippe." | |
| return | |
| ;; | |
| esac | |
| return | |
| fi | |
| # 2. Wurde es früher ignoriert? | |
| if is_ignored "$NAME"; then | |
| echo -e "${YELLOW}Wurde markiert als 'IGNORE'.${NC}" | |
| echo -n " Trotzdem installieren? [y/N] " | |
| read -r choice | |
| if [[ ! "$choice" =~ ^[yY]$ ]]; then | |
| return | |
| fi | |
| # Remove from ignore list temporarily (sed in-place ist tricky cross-platform, wir lassen es einfach drin) | |
| fi | |
| # 3. Neuinstallation | |
| echo -e "${YELLOW}Nicht gefunden.${NC}" | |
| echo -n " Installieren? (Y)es / (n)o / (i)gnore forever: " | |
| read -r choice | |
| case "$choice" in | |
| n|N) | |
| echo " Skippe." | |
| ;; | |
| i|I) | |
| echo " Markiere als IGNORED." | |
| set_ignore "$NAME" | |
| ;; | |
| *) | |
| echo -e " ${BLUE}Installiere...${NC}" | |
| eval "$INSTALL_CMD" | |
| ;; | |
| esac | |
| } | |
| # Erkennt den Paketmanager | |
| detect_pkg_manager() { | |
| if command -v apt >/dev/null; then echo "sudo apt install -y"; | |
| elif command -v pacman >/dev/null; then echo "sudo pacman -S --noconfirm"; | |
| elif command -v dnf >/dev/null; then echo "sudo dnf install -y"; | |
| elif command -v brew >/dev/null; then echo "brew install"; | |
| else echo "UNKNOWN"; fi | |
| } | |
| PKG_CMD=$(detect_pkg_manager) | |
| # --- START --- | |
| load_state | |
| clear | |
| echo -e "${BLUE}🥧 GitPi Bootstrap Manager${NC}" | |
| echo "========================================" | |
| # --- 1. PRE-CHECK ZSH ENV --- | |
| echo -e "\n${YELLOW}--- 1. Environment Setup ---${NC}" | |
| if grep -q "export ZDOTDIR=" "$HOME/.zshenv" 2>/dev/null; then | |
| echo -e "✅ ZDOTDIR ist bereits gesetzt." | |
| else | |
| echo -n "Setze ZDOTDIR in ~/.zshenv (Zwingend für GitPi Zsh Setup)? [Y/n] " | |
| read -r choice | |
| if [[ ! "$choice" =~ ^[nN]$ ]]; then | |
| echo 'export ZDOTDIR="$HOME/.config/zsh"' >> "$HOME/.zshenv" | |
| echo "✅ Erledigt." | |
| fi | |
| fi | |
| # --- 2. SYSTEM TOOLS --- | |
| echo -e "\n${YELLOW}--- 2. System Tools ---${NC}" | |
| if [ "$PKG_CMD" == "UNKNOWN" ]; then | |
| echo -e "${RED}Kein bekannter Paketmanager gefunden! Manuelle Installation nötig.${NC}" | |
| else | |
| ask_install "Git" "git" "$PKG_CMD git" | |
| ask_install "Zsh" "zsh" "$PKG_CMD zsh" | |
| ask_install "Python3" "python3" "$PKG_CMD python3" | |
| ask_install "Micro Editor" "micro" "$PKG_CMD micro" | |
| ask_install "Broot" "broot" "$PKG_CMD broot" | |
| ask_install "Kitty Terminal" "kitty" "$PKG_CMD kitty" | |
| # Mise (Version Manager) hat oft eigenen Installer | |
| ask_install "Mise" "mise" "curl https://mise.run | sh" | |
| fi | |
| # --- 3. NODE & NPM --- | |
| echo -e "\n${YELLOW}--- 3. Node.js Ecosystem ---${NC}" | |
| # Node selbst | |
| ask_install "Node.js" "node" "$PKG_CMD nodejs npm" | |
| # Globale NPM Pakete (nur wenn Node und NPM da sind) | |
| if command -v npm >/dev/null; then | |
| NPM_CMD="sudo npm install -g" | |
| ask_install "PNPM" "pnpm" "$NPM_CMD pnpm" | |
| ask_install "TypeScript (tsc)" "tsc" "$NPM_CMD typescript" | |
| ask_install "Zionide" "zionide" "$NPM_CMD zionide" | |
| ask_install "Qwen-Code AI" "qwen-code" "$NPM_CMD @qwen-code/qwen-code" | |
| else | |
| echo -e "${RED}Node/NPM fehlt. Überspringe NPM Pakete.${NC}" | |
| fi | |
| # --- 4. SPEZIAL & GUI --- | |
| echo -e "\n${YELLOW}--- 4. Spezial Apps ---${NC}" | |
| # VS Code Insiders (Schwer per Script universell zu lösen) | |
| install_vscode() { | |
| echo "Versuche Snap Installation..." | |
| if command -v snap >/dev/null; then sudo snap install code-insiders --classic; | |
| else echo "${RED}Kein Snap gefunden. Bitte manuell installieren.${NC}"; fi | |
| } | |
| ask_install "VS Code Insiders" "code-insiders" "install_vscode" | |
| # --- 5. GITPI VERBINDUNG --- | |
| echo -e "\n${YELLOW}--- 5. GitPi Connection ---${NC}" | |
| if [ -d "$TARGET_DIR" ] && [ -d "$TARGET_DIR/.git" ]; then | |
| echo -e "${GREEN}Repo bereits geklont.${NC}" | |
| else | |
| echo -n "Verbindung zu $PI_HOST herstellen und Repo clonen? [Y/n] " | |
| read -r choice | |
| if [[ ! "$choice" =~ ^[nN]$ ]]; then | |
| # SSH Check | |
| if [ ! -f "$HOME/.ssh/id_ed25519" ] && [ ! -f "$HOME/.ssh/id_rsa" ]; then | |
| echo "🔑 Erstelle SSH Key..." | |
| ssh-keygen -t ed25519 -f "$HOME/.ssh/id_ed25519" -N "" | |
| fi | |
| # Auto-Auth | |
| if ! ssh -q -o BatchMode=yes -o ConnectTimeout=5 "$PI_USER@$PI_HOST" exit 2>/dev/null; then | |
| echo "⚠️ Kein Zugriff. Brauche Admin-Passwort vom Pi:" | |
| read -p "Admin User auf Pi: " ADMIN_USER | |
| ssh-copy-id -i "$HOME/.ssh/id_ed25519.pub" "$ADMIN_USER@$PI_HOST" | |
| # Trick: ssh-copy-id kopiert oft zum Admin User, wir müssen den Key manuell zum git user schieben | |
| # (Hier verkürzt, in der Praxis reicht oft, wenn der Admin sudo hat) | |
| echo "ℹ️ Hinweis: Falls der Clone fehlschlägt, stelle sicher, dass der Key in /home/$PI_USER/.ssh/authorized_keys liegt." | |
| fi | |
| # Backup & Clone | |
| if [ -d "$TARGET_DIR" ]; then | |
| mv "$TARGET_DIR" "${TARGET_DIR}.backup.$(date +%s)" | |
| echo "Alte Config gesichert." | |
| fi | |
| git clone "$PI_USER@$PI_HOST:/home/$PI_USER/$REPO_NAME.git" "$TARGET_DIR" | |
| fi | |
| fi | |
| echo -e "\n${GREEN}🎉 Bootstrap abgeschlossen!${NC}" | |
| echo "Bitte neue Shell starten." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment