Fixes and refactors in install-gp.sh

This commit is contained in:
Matheus Albino Brunhara
2025-01-07 14:33:00 -03:00
parent 9f53345e49
commit 52570e526c

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/env bash
set -e set -e
show_help() { show_help() {
@@ -7,17 +7,21 @@ show_help() {
echo " --help | -h (Optional) Display help information on how to use this script" echo " --help | -h (Optional) Display help information on how to use this script"
echo " --version | --version (Required) Specify the GP version to install" echo " --version | --version (Required) Specify the GP version to install"
echo "" echo ""
echo " --no-download | --no-dl (Optional) Make the script not download the files from Artifactory" echo " --no-download-gp | --no-dl-gp (Optional) Make the script not download the files from Artifactory"
echo " --no-download-msgs | --no-dl-msgs (Optional) Make the script not download the MSGS files from Artifactory"
echo " --no-server | --no-svr (Optional) Make the script not install GP server" echo " --no-server | --no-svr (Optional) Make the script not install GP server"
echo " --webmap | --wm (Optional) Make the script install the WebMap module" echo " --webmap | --wm (Optional) Make the script install the WebMap module"
echo " --apache (Optional) Make the script install the Apache dependency for WebMap module" echo " --apache (Optional) Make the script install the Apache dependency for WebMap module"
echo " --msgs4 (Optional) Make the script install the version 4 of the WebMap module"
} }
version='' version=''
should_download=true should_download_packages_gp=true
should_download_packages_msgs=true
should_install_gp=true should_install_gp=true
should_install_geoserver=false should_install_geoserver=true
should_install_apache=false should_install_apache=false
should_install_msgs_4=false
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case "$1" in case "$1" in
@@ -29,8 +33,16 @@ while [ "$#" -gt 0 ]; do
version="$2" version="$2"
shift 2 shift 2
;; ;;
--no-download | --no-dl) --no-download-gp | --no-dl-gp)
should_download=false should_download_packages_gp=false
shift
;;
--no-download-msgs | --no-dl-msgs)
should_download_packages_msgs=false
shift
;;
--no-server | --no-svr)
should_install_gp=false
shift shift
;; ;;
--no-server | --no-svr) --no-server | --no-svr)
@@ -41,6 +53,10 @@ while [ "$#" -gt 0 ]; do
should_install_apache=true should_install_apache=true
shift shift
;; ;;
--msgs4)
should_install_msgs_4=true
shift
;;
*) shift ;; *) shift ;;
esac esac
done done
@@ -126,18 +142,15 @@ validate_repo_script $script_explode_java_files_filename
script_disable_dbversion_check_filename='disable-dbversion-check-on-software-info-file.sh' script_disable_dbversion_check_filename='disable-dbversion-check-on-software-info-file.sh'
validate_repo_script $script_disable_dbversion_check_filename validate_repo_script $script_disable_dbversion_check_filename
NEOCAD_INSTALLATION=false script_mise_exec='disable-dbversion-check-on-software-info-file.sh'
validate_repo_script $script_mise_exec
if [[ $version == *"NEOCAD"* ]]; then
NEOCAD_INSTALLATION=true
fi
# download files # download files
base_url='artifactory.cpqd.com.br/artifactory' base_url='artifactory.cpqd.com.br/artifactory'
gp_maven_repo=$(get_maven_repo $version) gp_maven_repo=$(get_maven_repo $version)
gp_artifactory_repo=$(get_artifactory_repo $version) gp_artifactory_repo=$(get_artifactory_repo $version)
if $should_download; then if $should_download_packages_gp; then
all_files=($(jf rt search --fail-no-op=true --sort-by=path "${gp_artifactory_repo}/gp/${version}/*" | jq -r '.[].path')) all_files=($(jf rt search --fail-no-op=true --sort-by=path "${gp_artifactory_repo}/gp/${version}/*" | jq -r '.[].path'))
if [ -z "$all_files" ]; then if [ -z "$all_files" ]; then
@@ -153,7 +166,6 @@ if $should_download; then
[[ $filename == "cpqd-dbmanager-customer"* ]] || [[ $filename == "cpqd-dbmanager-customer"* ]] ||
[[ $filename == "cpqd-etics-package-server"* ]] || [[ $filename == "cpqd-etics-package-server"* ]] ||
[[ $filename == "cpqd-etics-customer"* ]]; then [[ $filename == "cpqd-etics-customer"* ]]; then
wget $base_url/$pkg wget $base_url/$pkg
fi fi
done done
@@ -164,7 +176,7 @@ fi
cp $HOME/documents/ambients-gp/zips/* . cp $HOME/documents/ambients-gp/zips/* .
WILDFLY_WEB_FILENAME="wildfly-8*.zip" WILDFLY_WEB_FILENAME="wildfly-8*.zip"
WILDFLY_MSGS_FILENAME="wildfly-21*.zip" WILDFLY_MSGS_FILENAME_WC="wildfly-21*.zip"
if ! $should_install_geoserver; then if ! $should_install_geoserver; then
rm $WILDFLY_MSGS_FILENAME rm $WILDFLY_MSGS_FILENAME
@@ -179,7 +191,6 @@ if $should_install_gp; then
WILDFLY_WEB_DIRNAME='wildfly-server' WILDFLY_WEB_DIRNAME='wildfly-server'
unzip -d $WILDFLY_WEB_DIRNAME -qq $WILDFLY_WEB_FILENAME unzip -d $WILDFLY_WEB_DIRNAME -qq $WILDFLY_WEB_FILENAME
remove_empty_dir_after_extracting $WILDFLY_WEB_DIRNAME 'wildfly-' remove_empty_dir_after_extracting $WILDFLY_WEB_DIRNAME 'wildfly-'
chmod_sh_files_recursively $WILDFLY_WEB_DIRNAME chmod_sh_files_recursively $WILDFLY_WEB_DIRNAME
WILDFLY_WEB_CONFIGURATOR_DIRNAME=wildfly-configurator WILDFLY_WEB_CONFIGURATOR_DIRNAME=wildfly-configurator
@@ -201,8 +212,8 @@ if $should_install_gp; then
unzip -qq -o -d server cpqd-etics-customer-*-package-server* unzip -qq -o -d server cpqd-etics-customer-*-package-server*
cd server/dbmanager cd server/dbmanager
# removes '&' from the 'dbmanager.sh' script so this script can run things sequentially # # removes '&' from the 'dbmanager.sh' script so this script can run things sequentially
sed -i 's/org.eclipse.equinox.launcher.Main $ARGS &/org.eclipse.equinox.launcher.Main $ARGS/g' dbmanager.sh # sed -i 's/org.eclipse.equinox.launcher.Main $ARGS &/org.eclipse.equinox.launcher.Main $ARGS/g' dbmanager.sh
./dbmanager.sh ./dbmanager.sh
cd $root_dir/server/configurator/bin cd $root_dir/server/configurator/bin
@@ -239,66 +250,73 @@ fi
cd $root_dir cd $root_dir
gp_superparent_pom_filename_wc='cpqd-etics-super-parent-*.pom' msgs_package_filename=''
msgs_map_filename=''
cpqd_etics_super_parent_version=$version if $should_download_packages_msgs; then
if [[ "$version" =~ ^.*-T[0-9]*$ ]]; then if ! $should_install_msgs_4; then
cpqd_etics_super_parent_version="${version%-T[0-9]*}-SNAPSHOT" gp_superparent_pom_filename_wc='cpqd-etics-super-parent-*.pom'
cpqd_etics_super_parent_version=$version
if [[ "$version" =~ ^.*-T[0-9]*$ ]]; then
cpqd_etics_super_parent_version="${version%-T[0-9]*}-SNAPSHOT"
fi
gp_superparent_pom_dl="$gp_maven_repo/br/com/cpqd/etics/parent/cpqd-etics-super-parent/$cpqd_etics_super_parent_version/$gp_superparent_pom_filename_wc"
jf rt dl --flat --fail-no-op "$gp_superparent_pom_dl"
gp_superparent_pom_filename=$(find . -maxdepth 1 -type f -name "$gp_superparent_pom_filename_wc" -exec basename {} \;)
if [ -z "$gp_superparent_pom_filename" ]; then
echo "[ERROR] Could not find the $gp_superparent_pom_filename_wc filename"
echo "[ERROR] Attempted to download at URL \"$gp_superparent_pom_dl\""
exit 1
fi
cdk_version=$(xmlstarlet sel -N pom="http://maven.apache.org/POM/4.0.0" -t -v '/pom:project/pom:parent/pom:version' $gp_superparent_pom_filename)
cdk_maven_repo=$(get_maven_repo $cdk_version)
cdk_superparent_pom_filename_wc='cpqd-super-parent-*.pom'
cdk_superparent_pom_dl="$cdk_maven_repo/br/com/cpqd/parent/cpqd-super-parent/$cdk_version/$cdk_superparent_pom_filename_wc"
jf rt dl --flat --fail-no-op "$cdk_superparent_pom_dl"
cdk_superparent_pom_filename=$(find . -maxdepth 1 -type f -name "$cdk_superparent_pom_filename_wc" -exec basename {} \;)
if [ -z "$cdk_superparent_pom_filename" ]; then
echo "[ERROR] Could not find the $cdk_superparent_pom_filename_wc filename"
exit 1
fi
msgs_version=$(xmlstarlet sel -N pom="http://maven.apache.org/POM/4.0.0" -t -v '/pom:project/pom:properties/pom:cpqd.msgs.version' $cdk_superparent_pom_filename)
rm $gp_superparent_pom_filename $cdk_superparent_pom_filename
else
msgs_version='4.0.0'
fi
msgs_maven_repo=$(get_maven_repo $msgs_version)
msgs_package_filename_wc="cpqd-msgs-package-*.zip"
jf rt dl --flat --fail-no-op "$msgs_maven_repo/br/com/cpqd/msgs/package/cpqd-msgs-package/$msgs_version/$msgs_package_filename_wc"
msgs_package_filename=$(find . -maxdepth 1 -type f -name "$msgs_package_filename_wc" -exec basename {} \;)
if [ -z "$msgs_package_filename" ]; then
echo "[ERROR] Could not find the $msgs_package_filename filename"
exit 1
fi
msgs_map_filename_wc="cpqd-msgs-map-*.zip"
jf rt dl --flat --fail-no-op "$msgs_maven_repo/br/com/cpqd/msgs/map/cpqd-msgs-map/$msgs_version/$msgs_map_filename_wc"
# msgs_map_filename=`find . -maxdepth 1 -type f -name "$msgs_map_filename_wc" -exec basename {} \;`
msgs_map_filename=$(find . -maxdepth 1 -type f -name "$msgs_map_filename_wc")
if [ -z "$msgs_map_filename" ]; then
echo "[ERROR] Could not find the $msgs_map_filename filename"
exit 1
fi
else
msgs_package_filename_wc="cpqd-msgs-package-*.zip"
msgs_package_filename=$(find . -maxdepth 1 -type f -name "$msgs_package_filename_wc" -exec basename {} \;)
fi fi
gp_superparent_pom_dl="$gp_maven_repo/br/com/cpqd/etics/parent/cpqd-etics-super-parent/$cpqd_etics_super_parent_version/$gp_superparent_pom_filename_wc"
jf rt dl --flat --fail-no-op "$gp_superparent_pom_dl"
gp_superparent_pom_filename=$(find . -maxdepth 1 -type f -name "$gp_superparent_pom_filename_wc" -exec basename {} \;)
if [ -z "$gp_superparent_pom_filename" ]; then
echo "[ERROR] Could not find the $gp_superparent_pom_filename_wc filename"
echo "[ERROR] Attempted to download at URL \"$gp_superparent_pom_dl\""
exit 1
fi
cdk_version=$(xmlstarlet sel -N pom="http://maven.apache.org/POM/4.0.0" -t -v '/pom:project/pom:parent/pom:version' $gp_superparent_pom_filename)
cdk_maven_repo=$(get_maven_repo $cdk_version)
cdk_superparent_pom_filename_wc='cpqd-super-parent-*.pom'
cdk_superparent_pom_dl="$cdk_maven_repo/br/com/cpqd/parent/cpqd-super-parent/$cdk_version/$cdk_superparent_pom_filename_wc"
jf rt dl --flat --fail-no-op "$cdk_superparent_pom_dl"
cdk_superparent_pom_filename=$(find . -maxdepth 1 -type f -name "$cdk_superparent_pom_filename_wc" -exec basename {} \;)
if [ -z "$cdk_superparent_pom_filename" ]; then
echo "[ERROR] Could not find the $cdk_superparent_pom_filename_wc filename"
exit 1
fi
msgs_version=$(xmlstarlet sel -N pom="http://maven.apache.org/POM/4.0.0" -t -v '/pom:project/pom:properties/pom:cpqd.msgs.version' $cdk_superparent_pom_filename)
if [ NEOCAD_INSTALLATION ]; then
# msgs_version='4.0.4-SNAPSHOT'
msgs_version='4.0.3'
fi
msgs_maven_repo=$(get_maven_repo $msgs_version)
msgs_package_filename_wc="cpqd-msgs-package-*.zip"
jf rt dl --flat --fail-no-op "$msgs_maven_repo/br/com/cpqd/msgs/package/cpqd-msgs-package/$msgs_version/$msgs_package_filename_wc"
msgs_package_filename=$(find . -maxdepth 1 -type f -name "$msgs_package_filename_wc" -exec basename {} \;)
if [ -z "$msgs_package_filename" ]; then
echo "[ERROR] Could not find the $msgs_package_filename filename"
exit 1
fi
msgs_map_filename_wc="cpqd-msgs-map-*.zip"
jf rt dl --flat --fail-no-op "$msgs_maven_repo/br/com/cpqd/msgs/map/cpqd-msgs-map/$msgs_version/$msgs_map_filename_wc"
# msgs_map_filename=`find . -maxdepth 1 -type f -name "$msgs_map_filename_wc" -exec basename {} \;`
msgs_map_filename=$(find . -maxdepth 1 -type f -name "$msgs_map_filename_wc")
if [ -z "$msgs_map_filename" ]; then
echo "[ERROR] Could not find the $msgs_map_filename filename"
exit 1
fi
rm $gp_superparent_pom_filename $cdk_superparent_pom_filename
msgs_package_dir=msgs-package msgs_package_dir=msgs-package
unzip -qq -d $msgs_package_dir $msgs_package_filename unzip -qq -d $msgs_package_dir $msgs_package_filename
remove_empty_dir_after_extracting $msgs_package_dir 'MSGS-' remove_empty_dir_after_extracting $msgs_package_dir 'MSGS-'
@@ -307,10 +325,9 @@ chmod_sh_files_recursively $msgs_package_dir
# TODO, verificar se existe variável de ambiente "JBOSS_HOME" setada # TODO, verificar se existe variável de ambiente "JBOSS_HOME" setada
# TODO, verificar se a porta 8080 está sendo usada # TODO, verificar se a porta 8080 está sendo usada
WILDFLY_GEOSERVER_DIRNAME='wildfly-geoserver' WILDFLY_GEOSERVER_FILENAME=$(find . -maxdepth 1 -type f -name "$WILDFLY_MSGS_FILENAME_WC")
WILDFLY_GEOSERVER_FILENAME_WC='wildfly-21*.zip' WILDFLY_GEOSERVER_DIRNAME='wildfly-geoserver'
WILDFLY_GEOSERVER_FILENAME=$(find . -maxdepth 1 -type f -name "$WILDFLY_GEOSERVER_FILENAME_WC")
unzip -d $WILDFLY_GEOSERVER_DIRNAME -qq $WILDFLY_GEOSERVER_FILENAME unzip -d $WILDFLY_GEOSERVER_DIRNAME -qq $WILDFLY_GEOSERVER_FILENAME
remove_empty_dir_after_extracting $WILDFLY_GEOSERVER_DIRNAME 'wildfly-' remove_empty_dir_after_extracting $WILDFLY_GEOSERVER_DIRNAME 'wildfly-'
@@ -318,10 +335,13 @@ chmod_sh_files_recursively $WILDFLY_GEOSERVER_DIRNAME
# TODO, a partir daqui, Java 11 se MSGS = 4? # TODO, a partir daqui, Java 11 se MSGS = 4?
# TODO, portas 8080 e 9990 não podem estar em uso # TODO, portas 8080 e 9990 não podem estar em uso
# APPSERVER_SETUP_CMD=("mise" "exec" "java@adoptopenjdk-11.0.24+8" "--" "$msgs_package_dir/appServerConfigurator/bin/setup.sh")
# eval "${APPSERVER_SETUP_CMD[@]}"
$msgs_package_dir/appServerConfigurator/bin/setup.sh $msgs_package_dir/appServerConfigurator/bin/setup.sh
# $msgs_package_dir/bin/setup.sh # $msgs_package_dir/bin/setup.sh
cp $root_dir/server/shared/config/map_info.xml $root_dir/$msgs_package_dir/geoserverConfigurator/config cp $root_dir/server/shared/config/map_info*.xml $root_dir/$msgs_package_dir/geoserverConfigurator/config
mkdir --parents $WILDFLY_GEOSERVER_DIRNAME/standalone/data_dir mkdir --parents $WILDFLY_GEOSERVER_DIRNAME/standalone/data_dir
@@ -330,10 +350,9 @@ $msgs_package_dir/geoserverConfigurator/bin/setup.sh
GEOSERVER_BIN_FILENAME=runstandalone.sh GEOSERVER_BIN_FILENAME=runstandalone.sh
unzip -qq -d $WILDFLY_GEOSERVER_DIRNAME/standalone server/installation/deployments/mapserver/mapserver-geoserver-data_dir.zip unzip -qq -d $WILDFLY_GEOSERVER_DIRNAME/standalone server/installation/deployments/mapserver/mapserver-geoserver-data_dir.zip
if [ ! $NEOCAD_INSTALLATION ]; then
# TODO, quebra aqui if ! $should_install_msgs_4; then
unzip -qq -d $WILDFLY_GEOSERVER_DIRNAME/standalone/data_dir/www/map $msgs_map_filename unzip -qq -d $WILDFLY_GEOSERVER_DIRNAME/standalone/data_dir/www/map $msgs_map_filename
else
GEOSERVER_BIN_FILENAME=standalone.sh GEOSERVER_BIN_FILENAME=standalone.sh
fi fi