-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-post.sh
More file actions
executable file
·43 lines (38 loc) · 1.54 KB
/
Copy pathbuild-post.sh
File metadata and controls
executable file
·43 lines (38 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
################################################################################
# Clean up from template processing in transient and development builds.
#
# This script delegates restoration to build-restore.sh to maintain DRY
# principle. It handles the logic of determining whether restoration should
# occur (for development or transient builds) and then calls the restoration
# script.
#
# Copyright 2025 William W. Kimball, Jr. MBA MSIS
# All rights reserved.
################################################################################
# Constants
MY_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LIB_DIRECTORY="${MY_DIRECTORY}/lib"
readonly MY_DIRECTORY LIB_DIRECTORY
# Import the shell helpers
if ! source "${LIB_DIRECTORY}/shell-helpers.sh"; then
echo "ERROR: Failed to import shell helpers!" >&2
exit 2
fi
# Accept command-line arguments
_deploymentStage=${1:?"ERROR: DEPLOYMENT_STAGE must be the first command-line argument!"}
_bakedComposeFile=${2:?"ERROR: DOCKER_COMPOSE_FILE must be the second command-line argument!"}
# Check if this is a transient build or development stage
_isTransientBuild=false
if [ "$_deploymentStage" == "development" ] \
|| [ -f "${MY_DIRECTORY}/.transient-build-marker" ]
then
_isTransientBuild=true
fi
# Bail out when not running a transient build or development mode
if ! $_isTransientBuild; then
logInfo "Skipping cleanup for non-transient build mode: ${_deploymentStage}"
exit 0
fi
# Delegate to build-restore.sh to perform the actual restoration
"${MY_DIRECTORY}/build-restore.sh"