Files
railwaysystem/scripts/bootstrap/install-kingbase-jdbc.sh
T

57 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
readonly EXPECTED_SHA256="346d5602477ed472b19c5e25729fff5a58b1d83cec56162a56ac4b86d9546c32"
readonly MAVEN_REPOSITORY="${HOME}/.m2/repository"
readonly INSTALLED_JAR="${MAVEN_REPOSITORY}/com/kingbase/kingbase8/8.6.0/kingbase8-8.6.0.jar"
sha256_file() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$1" | awk '{print $1}'
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$1" | awk '{print $1}'
else
echo "No SHA256 utility is available; install sha256sum or shasum." >&2
return 1
fi
}
if [[ -z "${KINGBASE_JDBC_JAR:-}" ]]; then
echo "KINGBASE_JDBC_JAR is not set." >&2
echo "Set it to the absolute path of the authorized Kingbase JDBC 8.6.0 vendor driver." >&2
exit 1
fi
if [[ ! -f "${KINGBASE_JDBC_JAR}" ]]; then
echo "KINGBASE_JDBC_JAR does not point to an existing regular file." >&2
exit 1
fi
source_sha256="$(sha256_file "${KINGBASE_JDBC_JAR}")"
if [[ "${source_sha256}" != "${EXPECTED_SHA256}" ]]; then
echo "Kingbase JDBC 8.6.0 source checksum mismatch." >&2
exit 1
fi
mvn install:install-file \
-Dfile="${KINGBASE_JDBC_JAR}" \
-DgroupId=com.kingbase \
-DartifactId=kingbase8 \
-Dversion=8.6.0 \
-Dpackaging=jar \
-DgeneratePom=true \
-Dmaven.repo.local="${MAVEN_REPOSITORY}"
if [[ ! -f "${INSTALLED_JAR}" ]]; then
echo "Kingbase JDBC 8.6.0 installation failed: local Maven artifact is missing." >&2
exit 1
fi
installed_sha256="$(sha256_file "${INSTALLED_JAR}")"
if [[ "${installed_sha256}" != "${EXPECTED_SHA256}" ]]; then
echo "Kingbase JDBC 8.6.0 installed artifact checksum mismatch." >&2
exit 1
fi
echo "Kingbase JDBC 8.6.0 provisioning PASS."