diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-01-12 14:56:43 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-01-12 14:56:43 +0000 |
commit | c3b8d11d5395a4ab8eb55680638ee3962179476a (patch) | |
tree | a9d46a02a603c46cfdf94cf5ff835a605993fcc5 /yarns/obnam.sh | |
parent | f9e7a6522af273346d77debce154dedd5e14c5a8 (diff) | |
download | obnam-c3b8d11d5395a4ab8eb55680638ee3962179476a.tar.gz |
More encryption tests
Diffstat (limited to 'yarns/obnam.sh')
-rw-r--r-- | yarns/obnam.sh | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/yarns/obnam.sh b/yarns/obnam.sh index 7abdae23..727ecd76 100644 --- a/yarns/obnam.sh +++ b/yarns/obnam.sh @@ -26,14 +26,21 @@ run_obnam() { local name="$1" shift + + # Create the config file, if it doesn't already exist. + local conf="$DATADIR/$name.conf" + if [ ! -e "$conf" ] + then + add_to_config "$name" client-name "$name" + fi + ( 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" "$@" + "$SRCDIR/obnam" --no-default-config --config "$conf" \ + --quiet --log-level debug --log "$DATADIR/obnam.log" "$@" ) } @@ -49,22 +56,57 @@ add_to_env() } -# Add a setting to an Obnam configuration file. +# Add a setting to the configuration file for a given client. add_to_config() { - local filename="$1" + local client="$1" + local filename="$DATADIR/$client.conf" local key="$2" local value="$3" if [ ! -e "$filename" ] then printf '[config]\n' > "$filename" + printf 'client-name = %s\n' "$client" >> "$filename" fi printf '%s = %s\n' "$key" "$value" >> "$filename" } +# Attempt to run a command, which may fail. Capture its stdout, +# stderr, and exit code. + +attempt() +{ + if "$@" \ + > "$DATADIR/attempt.stdout" \ + 2> "$DATADIR/attempt.stderr" + then + exit=0 + else + exit=$? + fi + echo "$exit" > "$DATADIR/attempt.exit" +} + + +# Match captured output from attempt against a regular expression. + +attempt_matches() +{ + grep "$2" "$DATADIR/attempt.$1" +} + + +# Check exit code of latest attempt. + +attempt_exit_was() +{ + grep -Fx "$1" "$DATADIR/attempt.exit" +} + + # Create a manifest with summain of a directory. manifest() |