diff options
author | Gustav Eek <gustav.eek@fripost.org> | 2024-05-30 07:57:03 +0200 |
---|---|---|
committer | Gustav Eek <gustav.eek@fripost.org> | 2024-06-10 08:55:34 +0200 |
commit | f7ba3ac8bdcf3ae8183f629c2d1d5a9d0fbb6a74 (patch) | |
tree | e0d41a7abb08601efa03226d92f2f0e60cd46897 /lib/sync | |
parent | 4bf6d364f3fdc60e35502952d3fd04e2ab724cab (diff) |
System. Provide general synchronization from shared folders
TODO. Document in README
Diffstat (limited to 'lib/sync')
-rwxr-xr-x | lib/sync | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/sync b/lib/sync new file mode 100755 index 0000000..72e9010 --- /dev/null +++ b/lib/sync @@ -0,0 +1,39 @@ +#!/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 +" + +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 |