Adds install-dbmanager.sh and updates miseExec.sh
This commit is contained in:
158
scripts/shell/job/gp/install-dbmanager.sh
Executable file
158
scripts/shell/job/gp/install-dbmanager.sh
Executable file
@@ -0,0 +1,158 @@
|
||||
#!/bin/env bash
|
||||
|
||||
show_help() {
|
||||
echo "Usage: $(basename $0) [--version|-v] [--help|h]"
|
||||
echo "Options:"
|
||||
echo " --help | -h (Optional) Display help information on how to use this script"
|
||||
echo " --version | -v (Required) GP's version"
|
||||
echo " --install-dir | -d (Required) Installation directory"
|
||||
echo " --customer | -c (Required) Customer name"
|
||||
echo " --no-download | -no-dl (Optional) Specify this if you already have the packages downloaded"
|
||||
}
|
||||
|
||||
VERSION=""
|
||||
INSTALL_DIR=""
|
||||
CUSTOMER=""
|
||||
SHOULD_DOWNLOAD=true
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--help | -h)
|
||||
show_help
|
||||
exit
|
||||
;;
|
||||
--version | -v)
|
||||
VERSION="$2"
|
||||
shift 2
|
||||
;;
|
||||
--install-dir | -d)
|
||||
INSTALL_DIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
--customer | -c)
|
||||
CUSTOMER="$2"
|
||||
shift 2
|
||||
;;
|
||||
--no-download | -no-dl)
|
||||
SHOULD_DOWNLOAD=false
|
||||
shift
|
||||
;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo 'Please inform a version with --version or -v'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$INSTALL_DIR" ]; then
|
||||
echo 'Please inform a installation directory with --install-dir or -d'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$CUSTOMER" ]; then
|
||||
echo 'Please inform a customer with --customer or -c'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if $SHOULD_DOWNLOAD; then
|
||||
commands_to_check=(wget)
|
||||
|
||||
commands_not_found=()
|
||||
for command in ${commands_to_check[@]}; do
|
||||
if ! command -v "$command" &>/dev/null; then
|
||||
commands_not_found+=("$command")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#commands_not_found[@]} -ne 0 ]; then
|
||||
echo 'The following commands are necessary in order to run the script, but were not found:'
|
||||
|
||||
for command in ${commands_not_found[@]}; do
|
||||
echo " \"$command\""
|
||||
done
|
||||
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ROOT_DIR=$(pwd)
|
||||
|
||||
if [ $(basename $ROOT_DIR) != "$INSTALL_DIR" ]; then
|
||||
mkdir --parents $INSTALL_DIR
|
||||
cd $INSTALL_DIR
|
||||
ROOT_DIR=$(pwd)
|
||||
fi
|
||||
|
||||
validate_dir() {
|
||||
DIR="$1"
|
||||
MESSAGE="$2"
|
||||
|
||||
if [ -z "$DIR" ]; then
|
||||
echo "$MESSAGE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -d "$DIR" ]; then
|
||||
echo "The provided directory '$DIR' does not exist"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
get_version_type_from_version() {
|
||||
version=$1
|
||||
|
||||
if [[ $version == *"-"* ]]; then
|
||||
echo 'snapshot'
|
||||
else
|
||||
echo 'release'
|
||||
fi
|
||||
}
|
||||
|
||||
get_artifactory_repo() {
|
||||
version=$1
|
||||
|
||||
case $(get_version_type_from_version $version) in
|
||||
'snapshot') echo 'oss-package-dev' ;;
|
||||
'release') echo 'oss-package-rel' ;;
|
||||
*) echo "[ERROR] Função \"$FUNCNAME\" recebeu um retorno inválido" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
chmod_sh_files_recursively() {
|
||||
DIRPATH=$1
|
||||
|
||||
find $DIRPATH -type f -name '*.sh' -exec chmod +x {} \;
|
||||
}
|
||||
|
||||
ARTIFACTORY_REPOSITORY=$(get_artifactory_repo "$VERSION")
|
||||
|
||||
DBMANAGER_PACKAGE_WILDCARD="$ARTIFACTORY_REPOSITORY/gp/$VERSION/package/cpqd-dbmanager-etics-package-*bin.zip"
|
||||
DBMANAGER_PACKAGE_ARTIFACTORY_PATH=$(jf rt search --fail-no-op=true --sort-by=path "${DBMANAGER_PACKAGE_WILDCARD}" | jq -r '.[].path')
|
||||
|
||||
if [ -z "$DBMANAGER_PACKAGE_ARTIFACTORY_PATH" ]; then
|
||||
echo "Could not find DBManager's package file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DBMANAGER_CUSTOMER_PACKAGE_WILDCARD="$ARTIFACTORY_REPOSITORY/gp/$VERSION/customer/$CUSTOMER/cpqd-dbmanager-customer-$CUSTOMER-*-bin.zip"
|
||||
DBMANAGER_CUSTOMER_PACKAGE_ARTIFACTORY_PATH=$(jf rt search --fail-no-op=true --sort-by=path "${DBMANAGER_CUSTOMER_PACKAGE_WILDCARD}" | jq -r '.[].path')
|
||||
|
||||
if [ -z "$DBMANAGER_CUSTOMER_PACKAGE_ARTIFACTORY_PATH" ]; then
|
||||
echo "Could not find DBManager's customer package file"
|
||||
echo "Did you inform a valid customer?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if $SHOULD_DOWNLOAD; then
|
||||
ARTIFACTORY_BASE_URL="https://artifactory.cpqd.com.br/artifactory"
|
||||
wget $ARTIFACTORY_BASE_URL/$DBMANAGER_PACKAGE_ARTIFACTORY_PATH
|
||||
wget $ARTIFACTORY_BASE_URL/$DBMANAGER_CUSTOMER_PACKAGE_ARTIFACTORY_PATH
|
||||
fi
|
||||
|
||||
DBMANAGER_PACKAGE_FILENAME=$(basename $DBMANAGER_PACKAGE_ARTIFACTORY_PATH)
|
||||
DBMANAGER_CUSTOMER_PACKAGE_FILENAME=$(basename $DBMANAGER_CUSTOMER_PACKAGE_ARTIFACTORY_PATH)
|
||||
|
||||
unzip -qq $DBMANAGER_PACKAGE_FILENAME
|
||||
unzip -qq -o $DBMANAGER_CUSTOMER_PACKAGE_FILENAME
|
||||
@@ -45,6 +45,7 @@ MISE_TOOL_MAVEN_3_9_9="3.9.9"
|
||||
FILENAME_GP_DEBUGPORTS="debugports-01.sh"
|
||||
FILENAME_GEOSERVER="runstandalone.sh"
|
||||
FILENAME_METAWIZARD="metawizard.sh"
|
||||
FILENAME_DBMANAGER="dbmanager.sh"
|
||||
|
||||
list_presets() {
|
||||
echo "Choose one of the presets:"
|
||||
@@ -54,6 +55,7 @@ list_presets() {
|
||||
echo " 4. Run Maven 3.3.3 with Java 8"
|
||||
echo " 5. Run Maven 3.8.4 with Java 11"
|
||||
echo " 6. Run MetaWizard with Java 8"
|
||||
echo " 7. Run DBManager with Java 8"
|
||||
}
|
||||
|
||||
read_preset_input() {
|
||||
@@ -84,6 +86,10 @@ select_preset_by_input() {
|
||||
set_executable_filename_if_it_is_null "$FILENAME_METAWIZARD"
|
||||
MISE_TOOLS=("java@$MISE_TOOL_JAVA_8")
|
||||
;;
|
||||
"7")
|
||||
set_executable_filename_if_it_is_null "$FILENAME_DBMANAGER"
|
||||
MISE_TOOLS=("java@$MISE_TOOL_JAVA_8")
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -101,7 +107,7 @@ select_preset_by_input
|
||||
|
||||
EXECUTABLE_FILENAME="./$EXECUTABLE_FILENAME"
|
||||
|
||||
if [ ! -f "$EXECUTABLE_FILENAME" ]; then
|
||||
if [ ! -f "$EXECUTABLE_FILENAME" ] && [ ! "$SHOULD_DRY_RUN" ]; then
|
||||
echo "The executable filename \"$EXECUTABLE_FILENAME\" does not exist in the current working directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user