#!/bin/bash # ============================================================================= # setup-win11.sh # One-command clone + automatic download of win11.qcow2 into win11-image/ # ============================================================================= set -e # Exit immediately if any command fails GITHUB_REPO="https://github.com/nullvoider07/windows11-base" REPO_NAME=$(basename "$GITHUB_REPO") echo "๐Ÿš€ Cloning GitHub repo: $GITHUB_REPO" # ----------------------------- Clone with GitHub CLI ----------------------- echo "๐Ÿ”ง Checking GitHub CLI..." if ! command -v gh >/dev/null 2>&1; then echo " GitHub CLI not found. Attempting to install..." # Try Homebrew (macOS/Linux) if command -v brew >/dev/null 2>&1; then brew install gh # Try APT (Debian/Ubuntu) elif command -v apt-get >/dev/null 2>&1; then curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \ sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && \ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \ sudo apt-get update && sudo apt-get install gh -y else echo "โŒ Unsupported package manager. Please install GitHub CLI manually:" echo " https://cli.github.com" exit 1 fi else echo " โœ… GitHub CLI already available." fi gh repo clone "$GITHUB_REPO" "$REPO_NAME" -- --depth=1 # ----------------------------- Create folder ------------------------------- echo "๐Ÿ“ Creating folder: win11-image/" mkdir -p "$REPO_NAME/win11-image" # ----------------------------- Ensure uv is available --------------------- echo "๐Ÿ”ง Checking uv..." if command -v uv >/dev/null 2>&1; then echo " uv already available โ€” skipping installation." else echo " Installing uv package manager..." curl -LsSf https://astral.sh/uv/install.sh | sh export PATH="$HOME/.cargo/bin:$HOME/.local/bin:$PATH" hash -r fi # ----------------------------- Ephemeral venv for huggingface-cli ---------- # Create a temporary venv, install huggingface-hub into it, run the download, # then delete the venv. This avoids all PATH/hash-cache/interpreter-mismatch # issues caused by stale system-wide or tool-level installs. echo "๐Ÿ”ง Creating ephemeral venv for huggingface-cli..." HF_VENV="$(mktemp -d)/hf-venv" # uv venv picks the correct current Python automatically uv venv "$HF_VENV" --quiet # Install directly into the venv โ€” no --system, no activation needed uv pip install --python "$HF_VENV/bin/python" transformers --quiet echo " โœ… huggingface-hub installed in ephemeral venv." # ----------------------------- Download QCOW2 ------------------------------ echo "๐Ÿ“ฅ Downloading win11.qcow2 (large file) into $REPO_NAME/win11-image/ ..." echo " (This may take a while โ€” progress bar will show)" # Call huggingface-cli directly by its venv path โ€” no PATH lookup, no cache "$HF_VENV/bin/hf" download NullVoider/windows11-base win11.qcow2 \ --local-dir "$REPO_NAME/win11-image" # ----------------------------- Cleanup venv -------------------------------- echo "๐Ÿงน Cleaning up ephemeral venv..." rm -rf "$HF_VENV" # ----------------------------- Final message ------------------------------- echo "" echo "โœ… SUCCESS!" echo " Repository cloned โ†’ $REPO_NAME/" echo " QCOW2 image ready at: $REPO_NAME/win11-image/win11.qcow2" echo "" echo " Next time just run: cd $REPO_NAME && git pull"