summaryrefslogtreecommitdiff
path: root/yarns/obnam.sh
diff options
context:
space:
mode:
Diffstat (limited to 'yarns/obnam.sh')
-rw-r--r--yarns/obnam.sh45
1 files changed, 41 insertions, 4 deletions
diff --git a/yarns/obnam.sh b/yarns/obnam.sh
index 09319b37..7abdae23 100644
--- a/yarns/obnam.sh
+++ b/yarns/obnam.sh
@@ -16,15 +16,52 @@
# =*= License: GPL-3+ =*=
-# Run Obnam in a safe way that ignore's any configuration files outside
-# the test. The first argument MUST be the client name.
+# Run Obnam in a safe way that ignore's any configuration files
+# outside the test. The first argument MUST be the client name. The
+# configuration file $DATADIR/$1.conf is used, if it exists. In addition,
+# the environment variables specified in $DATADIR/$1.env are added for
+# the duration of running Obnam.
run_obnam()
{
local name="$1"
shift
- "$SRCDIR/obnam" --no-default-config --quiet --client-name="$name" \
- --log-level debug --log "$DATADIR/obnam.log" "$@"
+ (
+ if [ -e "$DATADIR/$name.env" ]
+ then
+ . "$DATADIR/$name.env"
+ fi
+ "$SRCDIR/obnam" --no-default-config --config "$DATADIR/$name.conf" \
+ --quiet --client-name="$name" \
+ --log-level debug --log "$DATADIR/obnam.log" "$@"
+ )
+}
+
+
+# Add an environment variable to the Obnam run.
+
+add_to_env()
+{
+ local user="$1"
+ local var="$2"
+ local value="$3"
+ printf 'export %s=%s\n' "$var" "$value" >> "$DATADIR/$user.env"
+}
+
+
+# Add a setting to an Obnam configuration file.
+
+add_to_config()
+{
+ local filename="$1"
+ local key="$2"
+ local value="$3"
+
+ if [ ! -e "$filename" ]
+ then
+ printf '[config]\n' > "$filename"
+ fi
+ printf '%s = %s\n' "$key" "$value" >> "$filename"
}