diff --git a/push.sh b/push.sh index 9e018c2..fc8b333 100644 --- a/push.sh +++ b/push.sh @@ -17,7 +17,6 @@ source "$PWD/.ionvcs/src.config" # Set the remote path for rsync REMOTE_PATH="$csrc" - while getopts ":of" opt; do case $opt in f) @@ -26,6 +25,13 @@ while getopts ":of" opt; do esac done +# Set the destination folder +if [ -n "$2" ]; then + DEST_FOLDER="$PWD/$2" +else + DEST_FOLDER="$PWD" +fi + # 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") diff --git a/status.sh b/status.sh new file mode 100644 index 0000000..f78c2b0 --- /dev/null +++ b/status.sh @@ -0,0 +1,35 @@ +#!/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" + +REMOTE_PATH="$csrc" + +# Set the destination folder +if [ -n "$2" ]; then + DEST_FOLDER="$PWD/$2" +else + DEST_FOLDER="$PWD" +fi + +# 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" ]; then + echo "$DIFF_OUTPUT" + exit 1; +else + echo "no changes found!" +fi \ No newline at end of file