mirror of
https://github.com/ION606/VCS.git
synced 2026-05-14 22:16:55 +00:00
initial code commit
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
.ionvcs
|
||||||
@@ -1 +1,23 @@
|
|||||||
# VCS
|
# My remote sourcing system
|
||||||
|
|
||||||
|
## Running
|
||||||
|
## Option 1: The Script
|
||||||
|
just use `curl -fsSL -o ivcs.sh https://github.com/ION606/VCS/raw/main/setup.sh && chmod +x ivcs.sh && sudo ./ivcs.sh`
|
||||||
|
|
||||||
|
|
||||||
|
## Option 2: Maually
|
||||||
|
1. install `sshpass ssh pv` using your package manager
|
||||||
|
2. clone `https://github.com/ION606/VCS.git`
|
||||||
|
3. move `ionsrc.desktop` to wherever your system stores .desktop files
|
||||||
|
4. move the rest of the files to `~/ionsrc/`
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
format: `ionvcs <command> [args]`
|
||||||
|
|
||||||
|
| Command | Args | Description |
|
||||||
|
|----------|-------------|---------------------------------|
|
||||||
|
| clone | \<repo-url> | Clone a repository. |
|
||||||
|
| user | \<username> | Get user information. |
|
||||||
|
| init | N/A | Initialize a repository. |
|
||||||
|
| login | N/A | Login to the system. |
|
||||||
|
| push | [-f] | Push changes to the repository. |
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Navigate to the current working directory
|
||||||
|
cd "$PWD"
|
||||||
|
mkdir -p .ionvcs
|
||||||
|
|
||||||
|
# Check if a path is provided as an argument
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "please provide a path to clone (like ~/Desktop/code_here)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the destination folder
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
DEST_FOLDER="$PWD/$2"
|
||||||
|
else
|
||||||
|
DEST_FOLDER="$PWD"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the destination folder if it doesn't exist
|
||||||
|
mkdir -p "$DEST_FOLDER"
|
||||||
|
|
||||||
|
# Source the credentials file if it exists
|
||||||
|
if [ -f "$HOME/ionsrc/creds.txt" ]; then
|
||||||
|
source "$HOME/ionsrc/creds.txt"
|
||||||
|
else
|
||||||
|
echo "credentials file not found! (please use the login command)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the remote path for rsync
|
||||||
|
REMOTE_PATH="$username@$src:$1"
|
||||||
|
CONF_FILE="$PWD/.ionvcs/src.config"
|
||||||
|
|
||||||
|
# Write configuration details to the .ionvcs/src.config file
|
||||||
|
echo "csrc=$REMOTE_PATH" > "$CONF_FILE"
|
||||||
|
echo "lastdate=$(date)" >> "$CONF_FILE"
|
||||||
|
echo "user=$username" >> "$CONF_FILE"
|
||||||
|
|
||||||
|
chmod 600 "$CONF_FILE"
|
||||||
|
|
||||||
|
# Use rsync with sshpass to copy files with a progress bar
|
||||||
|
echo -n "cloning "
|
||||||
|
/usr/bin/sshpass -p "$password" rsync -a --info=progress2 --no-i-r -h -e ssh "$REMOTE_PATH" "$DEST_FOLDER" || { echo "failed to clone!"; exit 1; }
|
||||||
|
echo "done!"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -f "$HOME/ionsrc/creds.txt" ]; then
|
||||||
|
source "$HOME/ionsrc/creds.txt"
|
||||||
|
echo "logged in as $username!"
|
||||||
|
else
|
||||||
|
echo "no user found!"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Usage: ionvcs <command> [args]"
|
||||||
|
echo
|
||||||
|
printf "%-15s %-20s %-30s\n" "Command" "Args" "Description"
|
||||||
|
printf "%-15s %-20s %-30s\n" "-------" "-----" "-----------"
|
||||||
|
printf "%-15s %-20s %-30s\n" "clone" "<repo-url>" "Clone a repository."
|
||||||
|
printf "%-15s %-20s %-30s\n" "user" "<username>" "Get user information."
|
||||||
|
printf "%-15s %-20s %-30s\n" "init" "N/A" "Initialize a repository."
|
||||||
|
printf "%-15s %-20s %-30s\n" "login" "N/A" "Login to the system."
|
||||||
|
printf "%-15s %-20s %-30s\n" "push" "[-f]" "Push changes to the repository."
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# make sure the libraries are installed
|
||||||
|
sudo dnf -y install sshpass ssh pv || sudo apt-get -y install sshpass ssh pv
|
||||||
|
|
||||||
|
|
||||||
|
git clone https://github.com/ION606/VCS.git .ionvcs
|
||||||
|
sudo mv .ionvcs/ionsrc.desktop /usr/share/applications/ionsrc.desktop || echo "FAILED TO MAKE DESKTOP FOLDER"
|
||||||
|
mkdir -p ~/ionsrc
|
||||||
|
mv .ionvcs/* ~/ionsrc/
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Version=1.0
|
||||||
|
Name=ION VCS
|
||||||
|
Comment=A custom utility to fetch and send code to my server
|
||||||
|
Exec=~/ionsrc/run.sh
|
||||||
|
Icon=~/ionsrc/icon.png
|
||||||
|
Terminal=true
|
||||||
|
Type=Application
|
||||||
|
Categories=Utility;
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
CREDSFILE="$HOME/ionsrc/creds.txt"
|
||||||
|
|
||||||
|
read -p "Enter source IP/URL: " src;
|
||||||
|
read -p "Enter your username: " username;
|
||||||
|
read -sp "Enter your password: " password;
|
||||||
|
|
||||||
|
echo "";
|
||||||
|
|
||||||
|
echo "src=$src" > "$CREDSFILE";
|
||||||
|
echo "username=$username" >> "$CREDSFILE";
|
||||||
|
echo "password=$password" >> "$CREDSFILE";
|
||||||
|
|
||||||
|
# Secure the file
|
||||||
|
chmod 600 "$CREDSFILE";
|
||||||
|
|
||||||
|
echo "Logged in!";
|
||||||
|
exit;
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Navigate to the current working directory
|
||||||
|
cd "$PWD"
|
||||||
|
|
||||||
|
if [ ! -f "$HOME/ionsrc/creds.txt" ]; then
|
||||||
|
echo "credentials file not found!"
|
||||||
|
exit 1
|
||||||
|
elif [ ! -f "$PWD/.ionvcs/src.config"]; then
|
||||||
|
echo "config file not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source "$HOME/ionsrc/creds.txt"
|
||||||
|
source "$PWD/.ionvcs/src.config"
|
||||||
|
|
||||||
|
# Set the remote path for rsync
|
||||||
|
REMOTE_PATH="$csrc"
|
||||||
|
|
||||||
|
|
||||||
|
while getopts ":of" opt; do
|
||||||
|
case $opt in
|
||||||
|
f)
|
||||||
|
force_flag=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Use rsync with sshpass to check for differences without copying
|
||||||
|
DIFF_OUTPUT=$(/usr/bin/sshpass -p "$password" rsync -avcn --delete -e ssh "$REMOTE_PATH" "$DEST_FOLDER")
|
||||||
|
|
||||||
|
# Check if there are differences
|
||||||
|
if [ ! -z "$DIFF_OUTPUT" && ! $force_flag ]; then
|
||||||
|
echo "conflicts found between the local and remote directories (make sure they're correct and re-run using the -f flag):"
|
||||||
|
echo "$DIFF_OUTPUT"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use rsync with sshpass to copy files with a progress bar
|
||||||
|
echo -n "cloning..."
|
||||||
|
/usr/bin/sshpass -p "$password" rsync -avcn --exclude-from="$PWD/.ionign" --info=progress2 --no-i-r -h -e ssh "$DEST_FOLDER" "$REMOTE_PATH" || { echo "failed to clone!"; exit 1; }
|
||||||
|
echo "done!"
|
||||||
Reference in New Issue
Block a user