added base adding and removing

This commit is contained in:
ION606
2024-06-26 18:59:59 -04:00
parent 2362c01bc8
commit 742f3cae05
6 changed files with 128 additions and 5 deletions
+38 -4
View File
@@ -24,13 +24,47 @@ else
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_OUTPUT=$(/usr/bin/sshpass -p "$password" rsync -avcn --delete -e ssh "$REMOTE_PATH" "$DEST_FOLDER") || echo "FAILED TO CONNECT TO SOURCE!"
# Check if there are differences
if [ ! -z "$DIFF_OUTPUT" ]; then
echo -e "\e[1;32mdifferences found\e[0m"
echo "$DIFF_OUTPUT"
exit 1;
else
echo "no changes found!"
fi
echo "no changes found from remote"
fi
# Files
ogfiles=".ionvcs/ogfiles.config"
addfiles=".ionvcs/add.config"
# Check if the necessary files exist
if [ ! -f "$ogfiles" ]; then
echo "The file $ogfiles does not exist."
exit 1
fi
if [ ! -f "$addfiles" ]; then
echo "The file $addfiles does not exist."
exit 1
fi
# Read the .ionvcs/add.config into an array
mapfile -t add_files < "$addfiles"
mapfile -t all_files < "$ogfiles"
# Read the .ionvcs/ogfiles.config and process each line
while IFS= read -r file; do
if [ ! -f "$file" ]; then
# File is not in the current directory
echo -e "\e[0;31m$file\e[0m"
fi
done < "$ogfiles"
while IFS= read -r file; do
if ! (printf '%s\n' "${all_files[@]}" | grep -qx "$file"); then
# File is in .ionvcs/add.config
echo -e "\e[0;32m$file\e[0m"
fi
done < "$addfiles"