Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e
- # Check and install required tools
- for pkg in curl jq git; do
- if ! command -v $pkg >/dev/null 2>&1; then
- echo "$pkg not found. Installing..."
- apt update && apt install -y $pkg
- fi
- done
- # Set target folder from first argument or default
- TARGET_DIR="${1:-/BuzzExpress/webApp}"
- # Set JSON URL from second argument or default
- JSON_URL="${2:-https://pastebin.com/raw/6bb7jaZN}"
- # Prepare directory
- mkdir -p "$TARGET_DIR"
- cd "$TARGET_DIR"
- # Download JSON
- TMP_JSON="/tmp/repos.json"
- echo "Downloading JSON from $JSON_URL..."
- curl -s "$JSON_URL" -o "$TMP_JSON"
- # Clone each repo
- jq -c '.[]' "$TMP_JSON" | while read -r item; do
- REPO=$(echo "$item" | jq -r '.ssh')
- FOLDER=$(echo "$item" | jq -r '.folder')
- if [[ -z "$REPO" || -z "$FOLDER" ]]; then
- echo "Skipping invalid entry: $item"
- continue
- fi
- if [[ -d "$FOLDER" ]]; then
- echo "Folder $FOLDER already exists. Skipping..."
- continue
- fi
- echo "Cloning $REPO into $TARGET_DIR/$FOLDER"
- git clone "$REPO" "$FOLDER"
- done
- echo "All repositories cloned successfully into $TARGET_DIR."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement