Allow set but empty envvars
This commit is contained in:
+5
-1
@@ -6,11 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [3.0.0] - 2022-02-01
|
||||||
### Added
|
### Added
|
||||||
- Allow extra arguments to restic-backup with `$RESTIC_BACKUP_EXTRA_ARGS`.
|
- Allow extra arguments to restic-backup with `$RESTIC_BACKUP_EXTRA_ARGS`.
|
||||||
- Add `$RESTIC_VERBOSITY_LEVEL` for debugging.
|
- 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.
|
- Added linter (`shellcheck(1)`) that is run on push and PRs.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ set -euo pipefail
|
|||||||
assert_envvars() {
|
assert_envvars() {
|
||||||
local varnames=("$@")
|
local varnames=("$@")
|
||||||
for varname in "${varnames[@]}"; do
|
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} ]; then
|
||||||
if [ -z ${!varname+x} ] || [ -z "${!varname}" ] ; 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
|
||||||
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
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ set -euo pipefail
|
|||||||
assert_envvars() {
|
assert_envvars() {
|
||||||
local varnames=("$@")
|
local varnames=("$@")
|
||||||
for varname in "${varnames[@]}"; do
|
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} ]; then
|
||||||
if [ -z ${!varname+x} ] || [ -z "${!varname}" ] ; 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
|
||||||
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
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user