2022-06-02 21:26:42 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -o pipefail -o errexit
|
2023-02-15 23:50:55 +03:00
|
|
|
BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
|
2022-06-02 21:26:42 +03:00
|
|
|
|
|
|
|
# Error handling
|
|
|
|
handle_error() {
|
|
|
|
read -n1 -r -p "FAILED: line $1, exit code $2. Press any key to exit..." _
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
trap 'handle_error $LINENO $?' ERR
|
|
|
|
|
|
|
|
# Load default script environment variables
|
|
|
|
# shellcheck source=.script_env
|
|
|
|
. "${BASEDIR}/.script_env"
|
|
|
|
|
2022-06-29 16:49:38 +03:00
|
|
|
mkdir -pv "${BASEDIR}/../${OUTPUT_FOLDER}"
|
2022-06-02 21:26:42 +03:00
|
|
|
|
2022-06-29 16:49:38 +03:00
|
|
|
pushd "${VAULT_FOLDER}/apps/web"
|
2022-06-02 21:26:42 +03:00
|
|
|
|
|
|
|
VAULT_VERSION=$(get_web_vault_version)
|
2022-12-18 01:52:19 +03:00
|
|
|
OUTPUT_NAME="${BASEDIR}/../${OUTPUT_FOLDER}/bw_web_${VAULT_VERSION}"
|
|
|
|
DATE_FORMAT="${DATE_FORMAT:-%Y-%m-%dT%H:%M:%S%z}"
|
|
|
|
|
|
|
|
# Preserve previous output
|
|
|
|
if [[ -f "${OUTPUT_NAME}.tar.gz" ]];
|
|
|
|
then
|
2023-02-15 23:50:55 +03:00
|
|
|
DATE_SUFFIX=$(date -r "${OUTPUT_NAME}.tar.gz" +"${DATE_FORMAT}")
|
2022-12-18 01:52:19 +03:00
|
|
|
mv "${OUTPUT_NAME}.tar.gz" "${OUTPUT_NAME}_${DATE_SUFFIX}.tar.gz"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Cleanup previous output directory
|
|
|
|
if [[ -d "${OUTPUT_NAME}" ]];
|
|
|
|
then
|
|
|
|
rm -rf "${OUTPUT_NAME}"
|
|
|
|
fi
|
2022-06-02 21:26:42 +03:00
|
|
|
|
|
|
|
mv build web-vault
|
2022-06-29 16:49:38 +03:00
|
|
|
# Tar the web-vault
|
2023-02-15 23:50:55 +03:00
|
|
|
# Check if we are using bsdtar or gnu-tar, bsdtar does not support --owner/--group
|
|
|
|
if [[ "$(tar --version)" =~ .*bsdtar.* ]];
|
|
|
|
then
|
|
|
|
tar -czvf "${OUTPUT_NAME}.tar.gz" web-vault
|
|
|
|
else
|
|
|
|
tar -czvf "${OUTPUT_NAME}.tar.gz" web-vault --owner=0 --group=0
|
|
|
|
fi
|
2022-12-18 01:52:19 +03:00
|
|
|
|
2022-06-29 16:49:38 +03:00
|
|
|
# Copy the web-vault
|
2023-02-15 23:50:55 +03:00
|
|
|
cp -pR web-vault "${OUTPUT_NAME}"
|
2022-06-02 21:26:42 +03:00
|
|
|
mv web-vault build
|
|
|
|
|
|
|
|
popd
|