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

publish
1#!/bin/sh
2
3# extract site
4tmpdir="$(mktemp -d /tmp/.noxz.tech.sites.XXXXXX)"
5tar -xf "${1}" --strip-components 2 -C "${tmpdir}" \
6&& echo "noxz.tech extracted to '${tmpdir}'"
7
8# add 301 redirections
9[ -f ./config/301.cfg ] && printf '\nprocessing 301:\n' && while read -r line
10do
11	mkdir -p "${tmpdir}/${line%:*}"
12	printf '<meta http-equiv="refresh" content="0; url=%s" />' "${line#*:}" \
13		> "${tmpdir}/${line%:*}/index.html"
14	printf '  %s > %s\n' "${line%:*}" "${line#*:}"
15done < ./config/301.cfg && printf '\n'
16
17if [ $? -eq 0 ]; then
18	echo "Synchronizing ${tmpdir}/ => ${2}"
19	echo "Are you sure [y/N]?"
20	read response
21	case "$response" in
22	[yY][eE][sS]|[yY]) rsync -v -a --no-perms --delete-after "${tmpdir}/" "${2}" ;;
23	*) return ;;
24	esac
25fi
26
27# remove site extraction
28rm -rf "${tmpdir}"