Advertisement
Devalkoradiya

clone_script

Jul 19th, 2025
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. set -e
  4.  
  5. # Check and install required tools
  6. for pkg in curl jq git; do
  7.     if ! command -v $pkg >/dev/null 2>&1; then
  8.         echo "$pkg not found. Installing..."
  9.         apt update && apt install -y $pkg
  10.     fi
  11. done
  12.  
  13. # Set target folder from first argument or default
  14. TARGET_DIR="${1:-/BuzzExpress/webApp}"
  15.  
  16. # Set JSON URL from second argument or default
  17. JSON_URL="${2:-https://pastebin.com/raw/6bb7jaZN}"
  18.  
  19. # Prepare directory
  20. mkdir -p "$TARGET_DIR"
  21. cd "$TARGET_DIR"
  22.  
  23. # Download JSON
  24. TMP_JSON="/tmp/repos.json"
  25. echo "Downloading JSON from $JSON_URL..."
  26. curl -s "$JSON_URL" -o "$TMP_JSON"
  27.  
  28. # Clone each repo
  29. jq -c '.[]' "$TMP_JSON" | while read -r item; do
  30.     REPO=$(echo "$item" | jq -r '.ssh')
  31.     FOLDER=$(echo "$item" | jq -r '.folder')
  32.  
  33.     if [[ -z "$REPO" || -z "$FOLDER" ]]; then
  34.         echo "Skipping invalid entry: $item"
  35.         continue
  36.     fi
  37.  
  38.     if [[ -d "$FOLDER" ]]; then
  39.         echo "Folder $FOLDER already exists. Skipping..."
  40.         continue
  41.     fi
  42.  
  43.     echo "Cloning $REPO into $TARGET_DIR/$FOLDER"
  44.     git clone "$REPO" "$FOLDER"
  45. done
  46.  
  47. echo "All repositories cloned successfully into $TARGET_DIR."
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement