archive-logs

Iteratively archive newline separated log files

git clone https://git.8pit.net/archive-logs.git

 1#!/bin/sh
 2
 3cd "${0%/*}"
 4
 5export ARCHIVE_LOGS="${ARCHIVE_LOGS:-$(pwd)/../archive-logs}"
 6if [ ! -x "${ARCHIVE_LOGS}" ]; then
 7	printf "'%s' does not exist\n" "${ARCHIVE_LOGS}" 1>&2
 8	exit 1
 9fi
10
11export TESTDIR="${TMPDIR:-/tmp}/archive-logs-tests"
12trap "rm -rf '${TESTDIR}' 2>/dev/null" INT EXIT
13
14scriptdir="$(pwd)"
15for test in [0-9][0-9][0-9][0-9]:*; do
16	mkdir -p "${TESTDIR}"
17	cd "${TESTDIR}"
18	mkdir -p current current-expected archive archive-expected
19
20	name="${test##*/}"
21	printf "Running test case '%s': " "${name}"
22
23	"${scriptdir}/${test##*/}"
24	if [ $? -ne 0 ]; then
25		exit 1
26	fi
27
28	printf "OK\n"
29	cd "${scriptdir}" && rm -rf "${TESTDIR}"
30done
31
32exit 0