2 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
3 # vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
5 # This file contains functions shared between ninjahelper and backupninja.
7 #####################################################
11 # create a temporary file in a secure way.
14 local tempfile=`mktemp /tmp/$1.XXXXXXXX`
18 #####################################################
19 ## CONFIG-FILE RELATED FUNCTIONS
25 function setsection() {
30 # Retrieves the configuration variable named $1 from the current config
31 # file and section and echoes its value. If it is empty or not found, $2
33 function printconf() {
35 ret=`@AWK@ -f $libdirectory/parseini S=$CURRENT_SECTION P=$CURRENT_PARAM $CURRENT_CONF_FILE`
36 # if nothing is returned, set the default
37 if [ "$ret" == "" -a "$2" != "" ]; then
46 # Retrieves the configuration variable named $1 from the current config
47 # file and section and assigns its value to the global variable with the
48 # same name. If it is empty or not found, $2 is used.
51 ret=`printconf "$1" "$2"`
53 # replace * with %, so that it is not globbed.
54 ret="${ret//\\*/__star__}"
56 # We use escape the $ in $ret to delay expansion of $ret, so when $1
57 # is foo, eval sees foo=$ret and properly does the assignment
58 # (without the backslash, the right part of the assignment would be
59 # whatever is in ret and be subject to all kinds of expansion.