#!/usr/bin/env bash set -euo pipefail readonly EXPECTED_SHA256="e439bd1c48ce654748c4f333b874a61465702ceb18f29ee017c3f9bc47738c23" readonly MAVEN_REPOSITORY="${HOME}/.m2/repository" readonly INSTALLED_JAR="${MAVEN_REPOSITORY}/cn/com/kingbase/kingbase8/9.0.0/kingbase8-9.0.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 9.0.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 9.0.0 source checksum mismatch." >&2 exit 1 fi mvn org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file \ -Dfile="${KINGBASE_JDBC_JAR}" \ -DgroupId=cn.com.kingbase \ -DartifactId=kingbase8 \ -Dversion=9.0.0 \ -Dpackaging=jar \ -DgeneratePom=true \ -Dmaven.repo.local="${MAVEN_REPOSITORY}" if [[ ! -f "${INSTALLED_JAR}" ]]; then echo "Kingbase JDBC 9.0.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 9.0.0 installed artifact checksum mismatch." >&2 exit 1 fi echo "Kingbase JDBC 9.0.0 provisioning PASS."