From f818f011e3cdd5aa556ee140913f607381555cf5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 14 Nov 2019 19:20:16 +0100 Subject: [PATCH 01/22] Release 2.7 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/2.7 | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 doc/changes/2.7 diff --git a/ccollect b/ccollect index 6dd3fc0..9077e0f 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.6" -RELEASE="2019-11-12" +VERSION="2.7" +RELEASE="2019-11-14" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 37e4eaf..2478265 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.6, for ccollect 2.6, Initial Version from 2006-01-13 +2.7, for ccollect 2.7, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/2.7 b/doc/changes/2.7 new file mode 100644 index 0000000..bafbb01 --- /dev/null +++ b/doc/changes/2.7 @@ -0,0 +1 @@ +* Fix shellcheck reported issues From 401dd4fa8e4a50e7f8a706c35bf5c505b874a205 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Nov 2019 08:29:21 +0100 Subject: [PATCH 02/22] Fix path with spaces in eval --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 9077e0f..d89aec1 100755 --- a/ccollect +++ b/ccollect @@ -79,7 +79,7 @@ lock_flock() # $1 = source to backup # shellcheck disable=SC2059 lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" - eval "exec ${LOCKFD}> ${lockfile}" + eval "exec ${LOCKFD}> '${lockfile}'" flock -n ${LOCKFD} && return 0 || return 1 } @@ -469,7 +469,7 @@ fi if [ "${PARALLEL}" ]; then mkfifo "${CONTROL_PIPE}" # fd 5 is tied to control pipe - eval "exec 5<>${CONTROL_PIPE}" + eval "exec 5<>'${CONTROL_PIPE}'" TRAPFUNC="${TRAPFUNC}; rm -f \"${CONTROL_PIPE}\"" # shellcheck disable=SC2064 trap "${TRAPFUNC}" 0 1 2 15 From 8f5d9b2c978916d3093ab7c2ce7bb0a94e580018 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Nov 2019 08:28:55 +0100 Subject: [PATCH 03/22] Add unit testing --- .gitignore | 1 - Makefile | 44 ++++++++++++++++++- test/conf/ccollect_local-with | 0 test/conf/ccollect_source | 0 test/conf/defaults/intervals/daily | 1 + test/conf/defaults/intervals/monthly | 1 + test/conf/defaults/intervals/normal | 1 + test/conf/defaults/intervals/weekly | 1 + test/conf/defaults/post_exec | 5 +++ test/conf/defaults/pre_exec | 5 +++ test/conf/defaults/sources/exclude | 1 + test/conf/defaults/sources/rsync_options | 0 test/conf/defaults/sources/verbose | 0 test/conf/defaults/verbose | 0 .../delete_incomplete/delete_incomplete | 0 .../sources/delete_incomplete/destination | 1 + test/conf/sources/delete_incomplete/exclude | 1 + test/conf/sources/delete_incomplete/source | 1 + .../sources/local-with&ersand/destination | 1 + .../conf/sources/local-with&ersand/exclude | 1 + test/conf/sources/local-with&ersand/source | 1 + .../local-with-interval/delete_incomplete | 0 .../sources/local-with-interval/destination | 1 + test/conf/sources/local-with-interval/exclude | 1 + .../local-with-interval/intervals/daily | 1 + test/conf/sources/local-with-interval/source | 1 + test/conf/sources/local-with-interval/verbose | 0 test/conf/sources/local/destination | 1 + test/conf/sources/local/exclude | 1 + test/conf/sources/local/no_verbose | 0 test/conf/sources/local/source | 1 + .../delete_incomplete | 0 .../destination | 1 + .../source with spaces and interval/exclude | 1 + .../source with spaces and interval/source | 1 + .../source with spaces and interval/verbose | 0 test/conf/sources/very_verbose/destination | 1 + test/conf/sources/very_verbose/exclude | 1 + test/conf/sources/very_verbose/source | 1 + test/conf/sources/very_verbose/summary | 0 test/conf/sources/very_verbose/verbose | 0 test/conf/sources/very_verbose/very_verbose | 0 test/conf/sources/with_exec/destination | 1 + test/conf/sources/with_exec/post_exec | 5 +++ test/conf/sources/with_exec/pre_exec | 5 +++ test/conf/sources/with_exec/source | 1 + test/exec.sh | 18 -------- test/local.sh | 1 - test/remote.sh | 1 - test/return-value.sh | 23 ---------- test/test-ccollect-tools.sh | 29 ------------ test/test-ccollect1.sh | 44 ------------------- 52 files changed, 89 insertions(+), 118 deletions(-) create mode 100644 test/conf/ccollect_local-with create mode 100644 test/conf/ccollect_source create mode 100644 test/conf/defaults/intervals/daily create mode 100644 test/conf/defaults/intervals/monthly create mode 100644 test/conf/defaults/intervals/normal create mode 100644 test/conf/defaults/intervals/weekly create mode 100755 test/conf/defaults/post_exec create mode 100755 test/conf/defaults/pre_exec create mode 100644 test/conf/defaults/sources/exclude create mode 100644 test/conf/defaults/sources/rsync_options create mode 100644 test/conf/defaults/sources/verbose create mode 100644 test/conf/defaults/verbose create mode 100644 test/conf/sources/delete_incomplete/delete_incomplete create mode 100644 test/conf/sources/delete_incomplete/destination create mode 100644 test/conf/sources/delete_incomplete/exclude create mode 100644 test/conf/sources/delete_incomplete/source create mode 100644 test/conf/sources/local-with&ersand/destination create mode 100644 test/conf/sources/local-with&ersand/exclude create mode 100644 test/conf/sources/local-with&ersand/source create mode 100644 test/conf/sources/local-with-interval/delete_incomplete create mode 100644 test/conf/sources/local-with-interval/destination create mode 100644 test/conf/sources/local-with-interval/exclude create mode 100644 test/conf/sources/local-with-interval/intervals/daily create mode 100644 test/conf/sources/local-with-interval/source create mode 100644 test/conf/sources/local-with-interval/verbose create mode 100644 test/conf/sources/local/destination create mode 100644 test/conf/sources/local/exclude create mode 100644 test/conf/sources/local/no_verbose create mode 100644 test/conf/sources/local/source create mode 100644 test/conf/sources/source with spaces and interval/delete_incomplete create mode 100644 test/conf/sources/source with spaces and interval/destination create mode 100644 test/conf/sources/source with spaces and interval/exclude create mode 100644 test/conf/sources/source with spaces and interval/source create mode 100644 test/conf/sources/source with spaces and interval/verbose create mode 100644 test/conf/sources/very_verbose/destination create mode 100644 test/conf/sources/very_verbose/exclude create mode 100644 test/conf/sources/very_verbose/source create mode 100644 test/conf/sources/very_verbose/summary create mode 100644 test/conf/sources/very_verbose/verbose create mode 100644 test/conf/sources/very_verbose/very_verbose create mode 100644 test/conf/sources/with_exec/destination create mode 100755 test/conf/sources/with_exec/post_exec create mode 100755 test/conf/sources/with_exec/pre_exec create mode 100644 test/conf/sources/with_exec/source delete mode 100755 test/exec.sh delete mode 100755 test/local.sh delete mode 100755 test/remote.sh delete mode 100755 test/return-value.sh delete mode 100644 test/test-ccollect-tools.sh delete mode 100755 test/test-ccollect1.sh diff --git a/.gitignore b/.gitignore index 4e9c74d..e5c18f6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ doc/man/*.html doc/man/*.htm doc/man/*.texi doc/man/*.man -test/* .*.swp doc/man/*.[0-9] doc/*.xml diff --git a/Makefile b/Makefile index 9b07e09..9b9f3e5 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,8 @@ DOCBDOCS = ${DOCS:.text=.docbook} DOC_ALL = ${HTMLDOCS} ${DBHTMLDOCS} ${TEXIDOCS} ${MANPDOCS} ${PDFDOCS} +TEST_LOG_FILE = /tmp/ccollect/ccollect.log + # # End user targets # @@ -202,9 +204,49 @@ dist: distclean documentation shellcheck: ./ccollect shellcheck -s sh -f gcc -x ./ccollect -test: $(CCOLLECT_SOURCE) /tmp/ccollect +test-nico: $(CCOLLECT_SOURCE) /tmp/ccollect cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect daily "$$s"; done touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect -a daily touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect -a -p daily + +test-dir-source: + mkdir -p /tmp/ccollect/source + cp -R -f ./* /tmp/ccollect/source + +test-dir-destination: + mkdir -p /tmp/ccollect/backup + +test-dir-destination-chint: + mkdir -p /tmp/ccollect/backup-chint + +test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint + for s in ./test/conf/sources/*; do \ + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename $$s)"; \ + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0"; \ + done + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -p daily + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + @printf "\nFixed intervals test ended successfully\n" + +test-interval-changing: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination-chint + rm -rf /tmp/ccollect/backup-chint/* + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" + printf "3" > ./test/conf/sources/local-with-interval/intervals/daily + for x in 1 2 3 4 5; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" + printf "5" > ./test/conf/sources/local-with-interval/intervals/daily + for x in 1 2 3 4 5 6 7; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" + printf "4" > ./test/conf/sources/local-with-interval/intervals/daily + for x in 1 2 3 4 5 6; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" + printf "3" > ./test/conf/sources/local-with-interval/intervals/daily + @printf "\nInterval changing test ended successfully\n" + +test: test-fixed-intervals test-interval-changing + test -f "${TEST_LOG_FILE}" + @printf "\nTests ended successfully\n" diff --git a/test/conf/ccollect_local-with b/test/conf/ccollect_local-with new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/ccollect_source b/test/conf/ccollect_source new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/defaults/intervals/daily b/test/conf/defaults/intervals/daily new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/test/conf/defaults/intervals/daily @@ -0,0 +1 @@ +5 diff --git a/test/conf/defaults/intervals/monthly b/test/conf/defaults/intervals/monthly new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/test/conf/defaults/intervals/monthly @@ -0,0 +1 @@ +4 diff --git a/test/conf/defaults/intervals/normal b/test/conf/defaults/intervals/normal new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/test/conf/defaults/intervals/normal @@ -0,0 +1 @@ +4 diff --git a/test/conf/defaults/intervals/weekly b/test/conf/defaults/intervals/weekly new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/conf/defaults/intervals/weekly @@ -0,0 +1 @@ +2 diff --git a/test/conf/defaults/post_exec b/test/conf/defaults/post_exec new file mode 100755 index 0000000..8aee58f --- /dev/null +++ b/test/conf/defaults/post_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +General post_exec executed. +###################################################################### diff --git a/test/conf/defaults/pre_exec b/test/conf/defaults/pre_exec new file mode 100755 index 0000000..ecd2857 --- /dev/null +++ b/test/conf/defaults/pre_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +General pre__exec executed. +###################################################################### diff --git a/test/conf/defaults/sources/exclude b/test/conf/defaults/sources/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/defaults/sources/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/defaults/sources/rsync_options b/test/conf/defaults/sources/rsync_options new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/defaults/sources/verbose b/test/conf/defaults/sources/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/defaults/verbose b/test/conf/defaults/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/delete_incomplete/delete_incomplete b/test/conf/sources/delete_incomplete/delete_incomplete new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/delete_incomplete/destination b/test/conf/sources/delete_incomplete/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/delete_incomplete/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/delete_incomplete/exclude b/test/conf/sources/delete_incomplete/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/delete_incomplete/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/delete_incomplete/source b/test/conf/sources/delete_incomplete/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/delete_incomplete/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/local-with&ersand/destination b/test/conf/sources/local-with&ersand/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/local-with&ersand/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/local-with&ersand/exclude b/test/conf/sources/local-with&ersand/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/local-with&ersand/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/local-with&ersand/source b/test/conf/sources/local-with&ersand/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/local-with&ersand/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/local-with-interval/delete_incomplete b/test/conf/sources/local-with-interval/delete_incomplete new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/local-with-interval/destination b/test/conf/sources/local-with-interval/destination new file mode 100644 index 0000000..4de7e06 --- /dev/null +++ b/test/conf/sources/local-with-interval/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup-chint diff --git a/test/conf/sources/local-with-interval/exclude b/test/conf/sources/local-with-interval/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/local-with-interval/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/local-with-interval/intervals/daily b/test/conf/sources/local-with-interval/intervals/daily new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/test/conf/sources/local-with-interval/intervals/daily @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/test/conf/sources/local-with-interval/source b/test/conf/sources/local-with-interval/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/local-with-interval/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/local-with-interval/verbose b/test/conf/sources/local-with-interval/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/local/destination b/test/conf/sources/local/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/local/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/local/exclude b/test/conf/sources/local/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/local/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/local/no_verbose b/test/conf/sources/local/no_verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/local/source b/test/conf/sources/local/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/local/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/source with spaces and interval/delete_incomplete b/test/conf/sources/source with spaces and interval/delete_incomplete new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/source with spaces and interval/destination b/test/conf/sources/source with spaces and interval/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/source with spaces and interval/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/source with spaces and interval/exclude b/test/conf/sources/source with spaces and interval/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/source with spaces and interval/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/source with spaces and interval/source b/test/conf/sources/source with spaces and interval/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/source with spaces and interval/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/source with spaces and interval/verbose b/test/conf/sources/source with spaces and interval/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/very_verbose/destination b/test/conf/sources/very_verbose/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/very_verbose/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/very_verbose/exclude b/test/conf/sources/very_verbose/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/very_verbose/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/very_verbose/source b/test/conf/sources/very_verbose/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/very_verbose/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/very_verbose/summary b/test/conf/sources/very_verbose/summary new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/very_verbose/verbose b/test/conf/sources/very_verbose/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/very_verbose/very_verbose b/test/conf/sources/very_verbose/very_verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/with_exec/destination b/test/conf/sources/with_exec/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/with_exec/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/with_exec/post_exec b/test/conf/sources/with_exec/post_exec new file mode 100755 index 0000000..abc0a40 --- /dev/null +++ b/test/conf/sources/with_exec/post_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +Source post_exec executed. +###################################################################### diff --git a/test/conf/sources/with_exec/pre_exec b/test/conf/sources/with_exec/pre_exec new file mode 100755 index 0000000..ba7b2af --- /dev/null +++ b/test/conf/sources/with_exec/pre_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +Source pre_exec executed. +###################################################################### diff --git a/test/conf/sources/with_exec/source b/test/conf/sources/with_exec/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/with_exec/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/exec.sh b/test/exec.sh deleted file mode 100755 index bdf601d..0000000 --- a/test/exec.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -host="home.schottelius.org" -host="" -set -x -pcmd() -{ - echo "$#", "$@" - if [ "$host" ]; then - ssh "$host" "$@" - else - $@ - fi -} - -#pcmd ls / -#pcmd cd /; ls "/is not there" -pcmd cd / && ls diff --git a/test/local.sh b/test/local.sh deleted file mode 100755 index c2430fd..0000000 --- a/test/local.sh +++ /dev/null @@ -1 +0,0 @@ -CCOLLECT_CONF=./conf ./ccollect.sh daily -v local1 diff --git a/test/remote.sh b/test/remote.sh deleted file mode 100755 index 2af364e..0000000 --- a/test/remote.sh +++ /dev/null @@ -1 +0,0 @@ -CCOLLECT_CONF=./conf ./ccollect.sh daily -v remote1 diff --git a/test/return-value.sh b/test/return-value.sh deleted file mode 100755 index 554def0..0000000 --- a/test/return-value.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -ls /surely-not-existent$$ 2>/dev/null - -if [ "$?" -ne 0 ]; then - echo "$?" -fi - -ls /surely-not-existent$$ 2>/dev/null - -ret=$? - -if [ "$ret" -ne 0 ]; then - echo "$ret" -fi - -# if is true, ls is fales -if [ "foo" = "foo" ]; then - ls /surely-not-existent$$ 2>/dev/null -fi - -# but that's still the return of ls and not of fi -echo $? diff --git a/test/test-ccollect-tools.sh b/test/test-ccollect-tools.sh deleted file mode 100644 index 5980d04..0000000 --- a/test/test-ccollect-tools.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# 2009 Nico Schottelius (nico-ccollect at schottelius.org) -# -# This file is part of ccollect. -# -# ccollect is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ccollect is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with ccollect. If not, see . -# -# -# Test the ccollect tools suite -# - -set -x - -tmp="$(mktemp /tmp/ccollect-tools.XXXXXXXXXXX)" - - -rm -rf "${tmp}" diff --git a/test/test-ccollect1.sh b/test/test-ccollect1.sh deleted file mode 100755 index c5acf54..0000000 --- a/test/test-ccollect1.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# -# Nico Schottelius -# Date: 27-Jan-2007 -# Last Modified: - -# Description: -# - -ccollect=../ccollect.sh -testdir="$(dirname $0)/test-backups" -confdir="$(dirname $0)/test-config" -source="$(hostname)" -source_source="/tmp" -interval="taeglich" - - -# backup destination -mkdir -p "$testdir" -source_dest="$(cd "$testdir"; pwd -P)" - -# configuration -mkdir -p "${confdir}/sources/${source}" -ln -s "$source_dest" "${confdir}/sources/${source}/destination" -echo "$source_source" > "${confdir}/sources/${source}/source" -touch "${confdir}/sources/${source}/summary" -touch "${confdir}/sources/${source}/verbose" - -mkdir -p "${confdir}/defaults/intervals/" -echo 3 > "${confdir}/defaults/intervals/$interval" - -# create backups - -CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a -touch "${source_source}/$(date +%s)-$$.1982" - -CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a -touch "${source_source}/$(date +%s)-$$.42" - -CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a - -du -sh "$testdir" -du -shl "$testdir" - -echo "Delete $testdir and $confdir after test" From 5ce3fddf6272cb443f37cde21512bce5eedf9d21 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 19 Nov 2019 18:25:10 +0100 Subject: [PATCH 04/22] Define gitlab CI --- .gitlab-ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..b499ddc --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,20 @@ +stages: + - test + +unit_tests: + stage: test + before_script: + - 'apk update' + - 'apk add make rsync' + script: + - make test + +shellcheck: + stage: test + before_script: + - 'apk update' + - 'apk add make' + - 'wget https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz' + - 'tar xf shellcheck-stable.linux.x86_64.tar.xz && mv shellcheck-stable/shellcheck /usr/bin/' + script: + - make shellcheck From 9ed5912461dcd9b56836ad643d1cfc8b9ff95983 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 08:42:42 +0100 Subject: [PATCH 05/22] Improve unit tests --- Makefile | 14 +++++++------- test/conf/defaults/post_exec | 6 ++---- test/conf/defaults/pre_exec | 6 ++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 9b9f3e5..ced0d28 100644 --- a/Makefile +++ b/Makefile @@ -224,26 +224,26 @@ test-dir-destination-chint: test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint for s in ./test/conf/sources/*; do \ CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename $$s)"; \ - test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0"; \ + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; }; \ done CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily - test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; } CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -p daily - test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; } @printf "\nFixed intervals test ended successfully\n" test-interval-changing: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination-chint rm -rf /tmp/ccollect/backup-chint/* - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" || { cat ${TEST_LOG_FILE}; exit 1; } printf "5" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6 7; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" || { cat ${TEST_LOG_FILE}; exit 1; } printf "4" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily @printf "\nInterval changing test ended successfully\n" diff --git a/test/conf/defaults/post_exec b/test/conf/defaults/post_exec index 8aee58f..0dac0ed 100755 --- a/test/conf/defaults/post_exec +++ b/test/conf/defaults/post_exec @@ -1,5 +1,3 @@ -#!/bin/cat +#!/bin/sh -###################################################################### -General post_exec executed. -###################################################################### +echo 'General post_exec executed.' diff --git a/test/conf/defaults/pre_exec b/test/conf/defaults/pre_exec index ecd2857..451fdad 100755 --- a/test/conf/defaults/pre_exec +++ b/test/conf/defaults/pre_exec @@ -1,5 +1,3 @@ -#!/bin/cat +#!/bin/sh -###################################################################### -General pre__exec executed. -###################################################################### +echo 'General pre__exec executed.' From 42bd1afb09ce17d84520ae2649c8af1dd91ced8b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 13:35:22 +0100 Subject: [PATCH 06/22] Fix quoting in tests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ced0d28..52b7a56 100644 --- a/Makefile +++ b/Makefile @@ -223,7 +223,7 @@ test-dir-destination-chint: test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint for s in ./test/conf/sources/*; do \ - CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename $$s)"; \ + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename '$$s')"; \ test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; }; \ done CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily From 6c24e8a7d35fd7132d2f2b6bbe3977159cf3054b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 13:35:22 +0100 Subject: [PATCH 07/22] Fix quoting in tests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 52b7a56..1e783fc 100644 --- a/Makefile +++ b/Makefile @@ -223,7 +223,7 @@ test-dir-destination-chint: test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint for s in ./test/conf/sources/*; do \ - CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename '$$s')"; \ + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename "$$s")"; \ test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; }; \ done CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily From 61ab45fc651b9fafb6da4de208fe0a7d5769c447 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 13:50:30 +0100 Subject: [PATCH 08/22] Fix excluding destination dir from removal Touch can lead to wrong ls order, and destination dir gets selected for removal. Use grep -v to exclude, instead of touch. --- ccollect | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ccollect b/ccollect index d89aec1..61e4ebd 100755 --- a/ccollect +++ b/ccollect @@ -767,20 +767,27 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Using ${oldest_bak} for destination dir ${destination_dir}" if mv "${oldest_bak}" "${destination_dir}"; then # Touch dest dir so it is not sorted wrong in listings below. - touch "${destination_dir}" + ls_rm_exclude=$(basename "${destination_dir}") # We have something to remove only if count > interval. remove="$((count - c_interval))" else _techo_err "Renaming oldest backup ${oldest_bak} to ${destination_dir} failed, removing it." remove="$((count - c_interval + 1))" + ls_rm_exclude="" fi if [ "${remove}" -gt 0 ]; then _techo "Removing ${remove} backup(s)..." - # shellcheck disable=SC2010 - ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ - _exit_err "Listing old backups failed" + if [ -z "${ls_rm_exclude}" ]; then + # shellcheck disable=SC2010 + ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + else + # shellcheck disable=SC2010 + ls -${TSORT}1r | grep -v "${ls_rm_exclude}" | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + fi delete_from_file "${TMP}" & fi From 589fed6107e4cd0c719e523b81f1ae7ff5b55677 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 14:41:41 +0100 Subject: [PATCH 09/22] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..563b438 --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Fix excluding destination dir from removal From 987277f1cf2d02f2c2e527c423f90becd0e0b4f9 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 20:52:48 +0100 Subject: [PATCH 10/22] Update Makefile Simplify and generalize. --- Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 1e783fc..789e099 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ ASCIIDOC=asciidoc DOCBOOKTOTEXI=docbook2x-texi DOCBOOKTOMAN=docbook2x-man XSLTPROC=xsltproc -XSL=/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl +XSL=/usr/local/share/xsl/docbook/html/docbook.xsl A2X=a2x prefix=/usr/packages/ccollect-git @@ -41,11 +41,7 @@ manlink=/usr/local/man/man1 path_dir=/usr/local/bin path_destination=${path_dir}/${CCOLLECT_DEST} - -# where to publish -host=localhost -dir=/home/users/nico/privat/rechner/netz/seiten/www.nico.schottelius.org/src/software/ccollect -docdir=${dir}/documentation +docs_archive_name=docs.tar # # Asciidoc will be used to generate other formats later @@ -91,6 +87,8 @@ all: @echo "info: only generate Texinfo" @echo "man: only generate manpage{s}" @echo "install: install ccollect to ${prefix}" + @echo "shellcheck: shellcheck ccollect script" + @echo "test: run unit tests" html: ${HTMLDOCS} htm: ${DBHTMLDOCS} @@ -179,9 +177,9 @@ pub: git push publish-doc: documentation - @echo "Transferring files to ${host}" @chmod a+r ${DOCS} ${DOC_ALL} - @tar c ${DOCS} ${DOC_ALL} | ssh ${host} "cd ${dir}; tar xv" + @tar cf ${docs_archive_name} ${DOCS} ${DOC_ALL} + @echo "Documentation files are in ${docs_archive_name}" # # Distribution From 5341de86fb331512dd442bbbcc8d68d20e6b06a5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 26 Nov 2019 06:10:17 +0100 Subject: [PATCH 11/22] Release 2.8 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/{next => 2.8} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/changes/{next => 2.8} (100%) diff --git a/ccollect b/ccollect index 61e4ebd..39799cd 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.7" -RELEASE="2019-11-14" +VERSION="2.8" +RELEASE="2019-11-26" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 2478265..84c326e 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.7, for ccollect 2.7, Initial Version from 2006-01-13 +2.8, for ccollect 2.8, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.8 similarity index 100% rename from doc/changes/next rename to doc/changes/2.8 From 109b70ea769755fbb576e3ee83af399fb5735e9e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 2 Dec 2019 09:26:47 +0100 Subject: [PATCH 12/22] gitlab runner should have necessary tools --- .gitlab-ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b499ddc..5391f4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,18 +3,10 @@ stages: unit_tests: stage: test - before_script: - - 'apk update' - - 'apk add make rsync' script: - make test shellcheck: stage: test - before_script: - - 'apk update' - - 'apk add make' - - 'wget https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz' - - 'tar xf shellcheck-stable.linux.x86_64.tar.xz && mv shellcheck-stable/shellcheck /usr/bin/' script: - make shellcheck From a261ef841eb76595d169eef334b8f004a2d3737c Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Sun, 24 May 2020 16:40:04 +0200 Subject: [PATCH 13/22] make rsync return code available in post_exec --- ccollect | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ccollect b/ccollect index 39799cd..679e3ca 100755 --- a/ccollect +++ b/ccollect @@ -824,6 +824,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do rsync "$@" "${source}" "${destination_dir}"; ret=$? _techo "Finished backup (rsync return code: $ret)." + # + # export rsync return code, might be useful in post_exec + # + export rsync_return_code=$ret + # # Set modification time (mtime) to current time, if sorting by mtime is enabled # From 28dec3694ae11b3924ba76c7de830183857d08bd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 24 May 2020 17:29:29 +0200 Subject: [PATCH 14/22] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..45097c7 --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Make rsync return code available in post_exec (Steffen Zieger) From 7a7dec7751862ca1eec30f2041c80e40746766b3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 May 2020 12:05:35 +0200 Subject: [PATCH 15/22] Release 2.9 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/{next => 2.9} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/changes/{next => 2.9} (100%) diff --git a/ccollect b/ccollect index 679e3ca..01c5d05 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.8" -RELEASE="2019-11-26" +VERSION="2.9" +RELEASE="2020-05-25" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 84c326e..bc8326a 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.8, for ccollect 2.8, Initial Version from 2006-01-13 +2.9, for ccollect 2.9, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.9 similarity index 100% rename from doc/changes/next rename to doc/changes/2.9 From 616b1d9e3e9cf996e1f90bfc8ede58143ed0e7e7 Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Mon, 25 May 2020 16:16:32 +0200 Subject: [PATCH 16/22] Add 'current' symlink to backup destinations --- ccollect | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ccollect b/ccollect index 01c5d05..b4af2f1 100755 --- a/ccollect +++ b/ccollect @@ -861,6 +861,16 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Warning: rsync failed with return code $ret." fi + # + # Create symlink to newest backup + # + # shellcheck disable=SC2010 + latest_dir="$(ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list content of ${ddir}." + + ln -snf "${ddir}${latest_dir}" "${ddir}current" || \ + _exit_err "Failed to create 'current' symlink." + # # post_exec # From 309d8dc773182a053619a93bc099f88f087b4c0e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 May 2020 17:52:23 +0200 Subject: [PATCH 17/22] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..1d1e85d --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Add 'current' symlink to backup destinations (Steffen Zieger) From 08cb857664a6dbcbacaffc020c747db554ebbf15 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 26 Aug 2020 08:36:43 +0200 Subject: [PATCH 18/22] Release 2.10 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/{next => 2.10} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/changes/{next => 2.10} (100%) diff --git a/ccollect b/ccollect index b4af2f1..2deaa2d 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.9" -RELEASE="2020-05-25" +VERSION="2.10" +RELEASE="2020-08-26" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index bc8326a..f075b9a 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.9, for ccollect 2.9, Initial Version from 2006-01-13 +2.10, for ccollect 2.10, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.10 similarity index 100% rename from doc/changes/next rename to doc/changes/2.10 From 2ca7598593befc52bff6b51b330bbcf508e20387 Mon Sep 17 00:00:00 2001 From: Jun Futagawa Date: Wed, 25 Nov 2020 11:24:37 +0900 Subject: [PATCH 19/22] Improve 'current' symlink to backup destinations --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 2deaa2d..8b8f9e5 100755 --- a/ccollect +++ b/ccollect @@ -868,7 +868,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do latest_dir="$(ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list content of ${ddir}." - ln -snf "${ddir}${latest_dir}" "${ddir}current" || \ + ln -snf "${ddir}/${latest_dir}" "${ddir}/current" || \ _exit_err "Failed to create 'current' symlink." # From 7d298d2b51f30f95407e2bdfc8e4e04fb14f66e2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 25 Nov 2020 16:17:29 +0100 Subject: [PATCH 20/22] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..81efe7b --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Fix 'current' symlink (Jun Futagawa) From 40dbfbd3a38b2064b095bea621600be1637dbd2d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 25 Nov 2020 16:20:28 +0100 Subject: [PATCH 21/22] Fix test: also count 'current' symlink --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 789e099..cda6d81 100644 --- a/Makefile +++ b/Makefile @@ -235,13 +235,13 @@ test-interval-changing: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination- test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" || { cat ${TEST_LOG_FILE}; exit 1; } + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" || { cat ${TEST_LOG_FILE}; exit 1; } printf "5" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6 7; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" || { cat ${TEST_LOG_FILE}; exit 1; } + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "6" || { cat ${TEST_LOG_FILE}; exit 1; } printf "4" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" || { cat ${TEST_LOG_FILE}; exit 1; } + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily @printf "\nInterval changing test ended successfully\n" From b50b3f64dc86182f93c348b4ff9d286d70bc7d28 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 25 Nov 2020 16:21:44 +0100 Subject: [PATCH 22/22] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e5c18f6..6a82cbe 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ doc/*.xml doc/*/*.xml *.texi *.fo +*.lock