From 476fafe75f23802ea9a28ed3c00a245c7db13f91 Mon Sep 17 00:00:00 2001 From: Mosder Date: Wed, 10 Jun 2026 03:23:10 +0200 Subject: added shell scripts to load config from repo and update repo from disk --- update_from_disk.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 update_from_disk.sh (limited to 'update_from_disk.sh') diff --git a/update_from_disk.sh b/update_from_disk.sh new file mode 100755 index 0000000..c0e9d55 --- /dev/null +++ b/update_from_disk.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Ensure good argument is passed +if [[ $# -ne 1 ]]; then + echo "Usage: $0 (desktop | laptop)" + exit 1 +elif [[ "$1" != "laptop" && "$1" != "desktop" ]]; then + echo "Target must be \"laptop\" or \"desktop\"" + exit 1 +fi + +TARGET=$1 +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" + fi +} + +update_repo() { + local repo_dir="$1" + cd "$repo_dir" + + find . -mindepth 1 | while read -r node; do + # ./node -> /node + src="${node#.}" + + if [[ -f "$src" ]]; then + copy_file "$src" "$node" + elif [[ ! -d "$src" ]]; then + echo "Skipped missing: $src" + fi + done +} + +update_repo "$SCRIPT_DIR/common" +update_repo "$SCRIPT_DIR/$TARGET" + +cd "$SCRIPT_DIR" +echo "Done." -- cgit v1.2.3