Skip to content

Commit

Permalink
Add version, changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
gav- committed Jul 5, 2023
1 parent 8e9b293 commit 645edb5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Version 1.0.0
- Initial release
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
30 changes: 25 additions & 5 deletions bin/kopia-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ set -u
# Show usage
#
usage() {
cat <<EO_USAGE
echo -n "
Version: ${KOPIA_WRAPPER_VERSION}
Usage: $(basename "$0") [-h|--help] <commands>
-h : This help.
Expand All @@ -36,7 +36,7 @@ Usage: $(basename "$0") [-h|--help] <commands>
maintenance-quick : Quick maintenance.
maintenance-full : Full maintenance.
EO_USAGE
"
}

##
Expand Down Expand Up @@ -351,13 +351,26 @@ run_maintenance_command() {
run_kopia_command "${kopia_command[@]}"
}

##
# Send first parameter to stderr, and exit with second parameter.
#
# Parameters:
# $1 - String to send to stderr
# $2 - Exit code
#
error_exit() {
echo "$1" 1>&2
exit $2
}

##
# Main function
#
# Globals:
# KOPIA_WRAPPER_HOME - Calculated parent directory of this script's dir.
# KOPIA_WRAPPER_COMMANDS - from command line parameters.
# KOPIA_WRAPPER_COMMAND_FAILED - false, set true if any command fails.
# KOPIA_WRAPPER_VERSION
# Variables defined in kopia-wrapper.conf
#
# Parameters:
Expand All @@ -367,13 +380,20 @@ main() {
KOPIA_WRAPPER_HOME="$(realpath -z "$0" | xargs -0 dirname -z | xargs -0 dirname)"
readonly KOPIA_WRAPPER_HOME

source "${KOPIA_WRAPPER_HOME}/kopia-wrapper.conf" || exit 1
source "${KOPIA_WRAPPER_HOME}/kopia-wrapper.conf" ||
error_exit "Failed to read kopia-wrapper.conf" 1

# Ensure kopia environment is configured
set -o allexport
source "${KOPIA_WRAPPER_HOME}/kopia-environment.conf" || exit 1
source "${KOPIA_WRAPPER_HOME}/kopia-environment.conf" ||
error_exit "Failed to read kopia-environment.conf" 1
set +o allexport

KOPIA_WRAPPER_VERSION="Unknown"
read -r KOPIA_WRAPPER_VERSION <"${KOPIA_WRAPPER_HOME}/VERSION" ||
error_exit "Failed to read VERSION" 1
readonly KOPIA_WRAPPER_VERSION

parse_parameters "$@"

KOPIA_WRAPPER_COMMAND_FAILED="false"
Expand Down

0 comments on commit 645edb5

Please sign in to comment.