aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGustav Eek <gustav.eek@fripost.org>2024-05-30 07:57:03 +0200
committerGustav Eek <gustav.eek@fripost.org>2024-07-13 09:28:26 +0200
commit7c7ea5ae027c0f0b353aef54749b34957cf05c59 (patch)
tree6d29f34ee32f9d64b65f0c2bada572e428b2a0c1 /lib
parentb520bb4d9182b5b25e8b5cb0835c9e563814b87d (diff)
System. Provide general synchronization from shared folders
TODO. Document usage in README (copy from conversation with SRE) Jul 2, 2024
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile18
-rwxr-xr-xlib/sync40
2 files changed, 52 insertions, 6 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 535809f..2c53bed 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -8,6 +8,10 @@ MINUTES ?= # will be compiled with *minutes* template
POLICY ?= # will be compiled with *by-laws* template
REPORTS ?= # will be compiled with *report* template
+# Repository root
+
+ROOT ?= $(shell git rev-parse --show-toplevel)
+
# Targets
.PHONY: all
@@ -48,20 +52,22 @@ $(addsuffix .pdf, $(REPORTS)): %.pdf: %.md
.PHONY: archive
ARCHIVE ?= archive
-ROOT ?= $(shell git rev-parse --show-toplevel)
SUFFIX ?= -$(subst /,,$(dir $(subst $(ROOT),,$(PWD))))
PDF ?= $(basename $(wildcard *.pdf))
-print:
- @echo ARCHIVE = $(ARCHIVE)
- @echo ROOT = $(ROOT)
- @echo SUFFIX = $(SUFFIX)
-
archive:
for p in $(PDF); do \
rsync $$p.pdf $(ROOT)/$(ARCHIVE)/$$p$(SUFFIX).pdf; \
done
+# Sync from shared meeting working directory
+
+SRC ?= $(FRIPOST_SYNC_SRC)
+
+sync:
+ FRIPOST_SYNC_SRC="$(SRC)" $(ROOT)/lib/sync
+
+
# Upload to server
.PHONY: send
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