From 7c7ea5ae027c0f0b353aef54749b34957cf05c59 Mon Sep 17 00:00:00 2001 From: Gustav Eek Date: Thu, 30 May 2024 07:57:03 +0200 Subject: System. Provide general synchronization from shared folders TODO. Document usage in README (copy from conversation with SRE) Jul 2, 2024 --- lib/sync | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 lib/sync (limited to 'lib/sync') diff --git a/lib/sync b/lib/sync new file mode 100755 index 0000000..1db2b30 --- /dev/null +++ b/lib/sync @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +HELP="Usage: sync [-h] + +Sync a source with a Git repository target. + +Parameters + Environmntal variables + FRIPOST_SYNC_SRC set source directory + -h help + +Set target directory where the repository is found and script +executed. Set source directory to for example a shared folder. Make +sure that all pahts are absolute." + +EXCL=" +*~* +*#* +Readme.md +lib +" + +trg="$PWD" +src="$FRIPOST_SYNC_SRC" +excl=$XDG_RUNTIME_DIR/${0##*/}-excl + +if [ "$1" == "-h" ]; then echo "$HELP"; exit; fi +if [ ! -d "$src" -o ! -d "$trg" ]; then + echo -n "Suorce '$src' and target '$trg' must be valid directories." + echo " See help: '${0} -h'." + exit 1 +fi + +echo "${0##*/}: I: Sync '${src}' to '${trg}'" 1>&2 + +echo "$EXCL" > $excl + +rsync -a --delete -P --exclude-from=$excl "${src}"/ "${trg}"/ \ + | grep -iv "^sending" +git -C "${trg}" status --short --branch -- cgit v1.2.3