aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMosder <xmosder12@gmail.com>2026-07-18 20:17:13 +0200
committerMosder <xmosder12@gmail.com>2026-07-18 20:17:13 +0200
commit4a9d9ac589f7ef41eb869dffc3d1b499bd8c653c (patch)
tree7948c6131f7af5d5a1731896898bb3d0e641d009
parentf3fcc7c9b4e603bede79e77cb05d505d0d83de3d (diff)
made loading and updating scripts more descriptive - now they show only operations that change something
-rwxr-xr-xload_config.sh15
-rwxr-xr-xupdate_from_disk.sh11
2 files changed, 21 insertions, 5 deletions
diff --git a/load_config.sh b/load_config.sh
index ec59828..0d947b9 100755
--- a/load_config.sh
+++ b/load_config.sh
@@ -14,6 +14,9 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
make_dir() {
local dir="$1"
+ if [ -d "$dir" ]; then
+ return 1
+ fi
echo "mkdir -p $dir"
if ! mkdir -p "$dir" 2>/dev/null; then
echo "Failed - using sudo..."
@@ -24,7 +27,17 @@ make_dir() {
copy_file() {
local src="$1"
local dest="$2"
- echo "cp -a $src $dest"
+
+ if [ -f "$dest" ]; then
+ if diff "$src" "$dest" &> /dev/null; then
+ return 1
+ else
+ echo "Updating $dest..."
+ fi
+ else
+ echo "$dest doesn't exist - copying..."
+ fi
+
if ! cp -a "$src" "$dest" 2>/dev/null; then
echo "Failed - using sudo..."
sudo cp -a "$src" "$dest"
diff --git a/update_from_disk.sh b/update_from_disk.sh
index c0e9d55..b113e31 100755
--- a/update_from_disk.sh
+++ b/update_from_disk.sh
@@ -15,10 +15,13 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
copy_file() {
local src="$1"
local dest="$2"
- echo "cp -a $src $dest"
- if ! cp -a "$src" "$dest" 2>/dev/null; then
- echo "Failed - using sudo..."
- sudo cp -a "$src" "$dest"
+ # update only if files are different
+ if ! diff "$src" "$dest" &>/dev/null; then
+ echo "Updating $dest..."
+ if ! cp -a "$src" "$dest" 2>/dev/null; then
+ echo "Failed - using sudo..."
+ sudo cp -a "$src" "$dest"
+ fi
fi
}