noxz-sites

A collection of a builder and various scripts creating the noxz.tech sites
git clone https://noxz.tech/git/noxz-sites.git
Log | Files | README | LICENSE

commit: c7a0db1781f7a043d25542e42a4eb3d789ec869a
parent: fe84b33eab31d9c0d818677bf30fd518acb2615f
author: Chris Noxz <chris@noxz.tech>
date:   Wed, 29 Dec 2021 13:18:58 +0100
change publish method to use rsync
MMakefile12++++++++----
Mconfig.mk2+-
Apublish19+++++++++++++++++++
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
@@ -9,18 +9,20 @@ all: clean check
 	@convert -density 1200 -resize 256x256 ./git.noxz.tech/pub/logo.svg ./noxz.tech/git/pub/logo.png
 	@
 	@echo assembling tar archive '${ASSEMBLE_TAR}'
-	@./assemble ${ASSEMBLE_TAR}
+	@./assemble "${ASSEMBLE_TAR}"
 
 check:
 	@./build check
 
 publish:
 	@echo publishing to web server...
-	@[ -f ${ASSEMBLE_TAR} ] && scp ${ASSEMBLE_TAR} ${PUBLISH_PATH} || echo must build first
+	@[ -f "${ASSEMBLE_TAR}" ] || { echo "'${ASSEMBLE_TAR}' is missing, must build first"; exit 1; }
+	@./publish "${ASSEMBLE_TAR}" "${PUBLISH_PATH}"
 
 ipfs:
 	@echo publishing to IPFS...
-	@[ -f ${ASSEMBLE_TAR} ] && ./ipfs-publish ${ASSEMBLE_TAR} || echo must build first
+	@[ -f "${ASSEMBLE_TAR}" ] || { echo "'${ASSEMBLE_TAR}' is missing, must build first"; exit 1; }
+	@./ipfs-publish "${ASSEMBLE_TAR}"
 
 clean:
 	@echo cleaning
@@ -31,7 +33,9 @@ clean:
 	@rm -f noxz.tech/pub/sitemap.xml
 	@rm -f git.noxz.tech/pub/logo.png
 	@rm -f git.noxz.tech/pub/sitemap.xml
-	@rm -f ${ASSEMBLE_TAR}
+	@rm -f "${ASSEMBLE_TAR}"
 
 clean-git:
 	@find ./git.noxz.tech/* -type d -prune ! -name "pub" -exec sh -ec 'rm -rf "$$0"' {} \;
+
+.PHONY: all check publish ipfs clean clean-git
diff --git a/config.mk b/config.mk
@@ -1,2 +1,2 @@
 ASSEMBLE_TAR = ./web.tar
-PUBLISH_PATH = anthra.system.local:/usr/local/share/noxz.tech/web.tar
+PUBLISH_PATH = anthra.system.local:/var/www/domains/noxz.tech
diff --git a/publish b/publish
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# extract site
+tmpdir="$(mktemp -d /tmp/.noxz.tech.sites.XXXXXX)"
+tar -xf "${1}" --strip-components 2 -C "${tmpdir}" \
+&& echo "noxz.tech extracted to '${tmpdir}'"
+
+if [ $? -eq 0 ]; then
+	echo "Synchronizing ${tmpdir}/ => ${2}"
+	echo "Are you sure [y/N]?"
+	read response
+	case "$response" in
+	[yY][eE][sS]|[yY]) rsync -v -a --delete-after "${tmpdir}/" "${2}" ;;
+	*) return ;;
+	esac
+fi
+
+# remove site extraction
+rm -rf "${tmpdir}"