Hello! We are running our annual fundraising. Please consider making a donation if you value this freely available service or want to support people around the world working towards liberatory social change. https://riseup.net/donate.

Commit 18d17bba authored by Emil Breiner's avatar Emil Breiner
Browse files

creation of backupninja.conf.d to customize backupninja.conf parameters



Introduction of a conf.d directory to safely override parameters from the backupninja.conf.

Change-Id: Ie17c4b9891f6eb31cb19a62ca09f0839aea7967e
Signed-Off-By: Emil Breiner's avatarEmil Breiner <emil.breiner@krumedia.com>
parent 5cc80402
......@@ -75,6 +75,9 @@ usecolors = yes
# default value for 'when'
when = everyday at 01:00
# conf.d for backupninja.conf overrides
config_d_directory = @CFGDIR@/backupninja.conf.d
# programs paths
# SLAPCAT=/usr/sbin/slapcat
# LDAPSEARCH=/usr/bin/ldapsearch
......
......@@ -58,20 +58,46 @@ function version_ge() {
function setfile() {
CURRENT_CONF_FILE=$1
# initialize empty and ommit a default value
CURRENT_CONF_D_DIR=""
getconf config_d_directory
# for consistency the config key is in lowercase
CURRENT_CONF_D_DIR=$config_d_directory
}
function setsection() {
CURRENT_SECTION=$1
}
#
# sets a global var with name equal to $1
# to the value of the configuration parameter $1
# $2 is the default.
#
# Begin by parsing the conf.d directory for configs.
# If the param is not found there fallback on the packaged backupninja.conf.
# if the param is still not found fallback to the default.
function getconf() {
ret=""
CURRENT_PARAM=$1
ret=`@AWK@ -f $libdirectory/parseini S=$CURRENT_SECTION P=$CURRENT_PARAM $CURRENT_CONF_FILE`
# check if conf.d directory exists
if [ -d "$CURRENT_CONF_D_DIR" ]; then
CURRENT_CONF_D_FILES=$CURRENT_CONF_D_DIR/*.conf
# iterate over all *.conf files in conf.d dir
for CURRENT_CONF_D_FILE in $CURRENT_CONF_D_FILES; do
# retrieve param from file
ret=`@AWK@ -f $libdirectory/parseini S=$CURRENT_SECTION P=$CURRENT_PARAM $CURRENT_CONF_D_FILE`
# exit the iteration if the param is set
if [ -n "$ret" ]; then
break
fi
done
fi
# after exiting the loop caused by a not set param parse the packaged backupninja.conf
if [ "$ret" == "" ]; then
ret=$(@AWK@ -f $libdirectory/parseini S=$CURRENT_SECTION P=$CURRENT_PARAM $CURRENT_CONF_FILE)
fi
# if nothing is returned, set the default
if [ "$ret" == "" -a "$2" != "" ]; then
ret="$2"
......
......@@ -124,6 +124,11 @@ These values for 'when' are invalid:
when = tuesday at 2
when = tues at 02
.TP
.B config_d_directory
Directory for configuration overrides. Files dropped in this directory have
to end with .conf. Misspelled parameter break the parsing of this directory.
.TP
.SH DEFAULTS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment