summaryrefslogtreecommitdiff
path: root/yarns/obnam.sh
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-01-12 13:36:45 +0000
committerLars Wirzenius <liw@liw.fi>2014-01-12 13:36:45 +0000
commitf9e7a6522af273346d77debce154dedd5e14c5a8 (patch)
tree732f8f1602c79633f4b7388716f5b4be73e50115 /yarns/obnam.sh
parent699670b2d671a7e0379eb6540ec02b67efdb634f (diff)
downloadobnam-f9e7a6522af273346d77debce154dedd5e14c5a8.tar.gz
Basic encrypted backup/restore test
This sets up a whole lot of infrastructure, too.
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"
}