1 Commits

Author SHA1 Message Date
Erik Westrup
b23d552f0b Allow set but empty envvars 2022-02-01 18:31:27 +01:00
3 changed files with 9 additions and 7 deletions

View File

@@ -6,11 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [3.0.1] - 2022-02-01
### Fixed
- Environment variable assertion should allow empty values e.g. `RESTIC_BACKUP_EXTRA_ARGS`
## [3.0.0] - 2022-02-01
### Added
- Allow extra arguments to restic-backup with `$RESTIC_BACKUP_EXTRA_ARGS`.
- Add `$RESTIC_VERBOSITY_LEVEL` for debugging.
- Assertion on all needed envionment variables in the backup and check scripts.
- Assertion on all needed environment variables in the backup and check scripts.
- Added linter (`shellcheck(1)`) that is run on push and PRs.
### Changed

View File

@@ -16,9 +16,8 @@ set -euo pipefail
assert_envvars() {
local varnames=("$@")
for varname in "${varnames[@]}"; do
# Check if variable is set, then if it is not empty (need to do both as of `set -u`).
if [ -z ${!varname+x} ] || [ -z "${!varname}" ] ; then
printf "%s must be set with a value for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2
if [ -z ${!varname+x} ]; then
printf "%s must be set for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2
exit 1
fi
done

View File

@@ -9,9 +9,8 @@ set -euo pipefail
assert_envvars() {
local varnames=("$@")
for varname in "${varnames[@]}"; do
# Check if variable is set, then if it is not empty (need to do both as of `set -u`).
if [ -z ${!varname+x} ] || [ -z "${!varname}" ] ; then
printf "%s must be set with a value for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2
if [ -z ${!varname+x} ]; then
printf "%s must be set for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2
exit 1
fi
done