Many fixes for install-gp.sh script

This commit is contained in:
Matheus Albino Brunhara
2024-11-14 11:50:25 -03:00
parent ce6f3ac7a8
commit 6a729d1a10

View File

@@ -2,14 +2,22 @@
set -e
show_help() {
echo "Usage: `basename $0` [--files|-f files]"
echo "Usage: $(basename $0) [--files|-f files]"
echo "Options:"
echo " --help | -h (Optional) Display help information on how to use this script"
echo " --version | --version (Required) Specify the GP version to install"
echo " --no-download true | --no-dl (Optional) Make the script not download the files from Artifactory"
echo " --no-webmap true | --no-wm (Optional) Make the script not install the WebMap module"
echo " --no-gp true | --no-gp (Optional) Make the script not install GP"
echo " --install-apache true (Optional) Make the script install the Apache dependency for WebMap module"
echo " --no-download | --no-dl (Optional) Make the script not download the files from Artifactory"
echo " --no-webmap | --no-wm (Optional) Make the script not install the WebMap module"
echo " --no-gp | --no-gp (Optional) Make the script not install GP"
echo " --install-apache (Optional) Make the script install the Apache dependency for WebMap module"
}
function test_data() {
version='10.30.500.0.0-NEOCAD-T07'
should_download=false
should_install_webmap=true
should_install_apache=true
should_install_gp=true
}
version=''
@@ -63,7 +71,7 @@ if [ $(basename $root_dir) != "$version" ]; then
root_dir=$(pwd)
fi
scripts_folder=$HOME/repos/personal/personal-devboot/scripts/shell/job/gp
scripts_folder=$HOME/documents/repos-personal/personal-devboot/scripts/shell/job/gp
if [ ! -d "$scripts_folder" ]; then
echo "The git repository \"CloudAlb/personal-devboot\" must be in the \"~/repos\" folder!"
@@ -109,6 +117,20 @@ get_artifactory_repo() {
esac
}
chmod_sh_files_recursively() {
DIRPATH=$1
find $DIRPATH -type f -name '*.sh' -exec chmod +x {} \;
}
remove_empty_dir_after_extracting() {
DIRPATH=$1
EXTRACTED_ROOT_DIRNAME=$2
mv $DIRPATH/**/* $DIRPATH
find $DIRPATH -maxdepth 1 -type d -not -path $DIRPATH -name "$EXTRACTED_ROOT_DIRNAME*" -exec rm -r {} \;
}
script_explode_java_files_filename='explode-java-files.sh'
validate_repo_script $script_explode_java_files_filename
@@ -121,12 +143,6 @@ gp_maven_repo=$(get_maven_repo $version)
gp_artifactory_repo=$(get_artifactory_repo $version)
if $should_download; then
if [[ $root_dir != *$version ]]; then
mkdir $version
cd $version
root_dir=$(pwd)
fi
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
@@ -148,11 +164,15 @@ if $should_download; then
done
fi
# cpqd-msgs-map-1.8.7-RC02-bin.zip cpqd-msgs-package-1.8.7-RC02-bin.zip wildfly-15.0.0.Final.zip wildfly-8.2.1.zip
cp /l/disk0/mbrunhara/gp/zips/* .
# cpqd-msgs-map-*-bin.zip cpqd-msgs-package-*-bin.zip wildfly-*.Final.zip wildfly-*.zip
# TODO, deve haver pastas do wildfly aqui
cp $HOME/documents/ambients-gp/zips/* .
WILDFLY_WEB_FILENAME="wildfly-8*.zip"
WILDFLY_MSGS_FILENAME="wildfly-21*.zip"
if ! $should_install_webmap; then
rm wildfly-15*.zip
rm $WILDFLY_MSGS_FILENAME
fi
if $should_install_gp; then
@@ -161,16 +181,22 @@ if $should_install_gp; then
mkdir -p cpqd-folders/audit cpqd-folders/exportacoes cpqd-folders/updater cpqd-folders/dataloader cpqd-folders/virtualdisk cpqd-folders/midmif
# unpacking files
unzip -qq wildfly-8.2.1.zip
find wildfly-8.2.1 -type f -name '*.sh' -exec chmod +x {} \;
WILDFLY_WEB_DIRNAME='wildfly-server'
unzip -d $WILDFLY_WEB_DIRNAME -qq $WILDFLY_WEB_FILENAME
remove_empty_dir_after_extracting $WILDFLY_WEB_DIRNAME 'wildfly-'
unzip -qq -d wildfly-configurator cpqd-etics-configurator-appserver-wildfly*
chmod +x wildfly-configurator/configurator/bin/setup.sh
chmod_sh_files_recursively $WILDFLY_WEB_DIRNAME
wildfly-configurator/configurator/bin/setup.sh
WILDFLY_WEB_CONFIGURATOR_DIRNAME=wildfly-configurator
unzip -qq -d $WILDFLY_WEB_CONFIGURATOR_DIRNAME cpqd-etics-configurator-appserver-wildfly-*
chmod_sh_files_recursively $WILDFLY_WEB_CONFIGURATOR_DIRNAME
wildfly_configurator_bin_file=$WILDFLY_WEB_CONFIGURATOR_DIRNAME/configurator/bin/setup.sh
$wildfly_configurator_bin_file
# doing this again to add permissions for newly created files by configurator
find wildfly-8.2.1 -type f -name '*.sh' -exec chmod +x {} \;
chmod_sh_files_recursively $WILDFLY_WEB_DIRNAME
unzip -qq -d server cpqd-etics-package-server*
mv server/cpqd*/* server/
@@ -181,7 +207,7 @@ if $should_install_gp; then
cd server/dbmanager
# 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
cd $root_dir/server/configurator/bin
@@ -221,7 +247,7 @@ cd $root_dir
gp_superparent_pom_filename_wc='cpqd-etics-super-parent-*.pom'
cpqd_etics_super_parent_version=$version
if [[ $version = *?-T[0-9]* ]]; then
if [[ "$version" =~ ^.*-T[0-9]*$ ]]; then
cpqd_etics_super_parent_version="${version%-T[0-9]*}-SNAPSHOT"
fi
@@ -250,6 +276,14 @@ 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)
NEOCAD_INSTALLATION=false
if [[ $version == *"NEOCAD"* ]]; then
# msgs_version='4.0.4-SNAPSHOT'
NEOCAD_INSTALLATION=true
msgs_version='4.0.3'
fi
msgs_maven_repo=$(get_maven_repo $msgs_version)
msgs_package_filename_wc="cpqd-msgs-package-*.zip"
@@ -273,37 +307,50 @@ fi
rm $gp_superparent_pom_filename $cdk_superparent_pom_filename
msgs_package_dir=$root_dir/msgs-package
msgs_package_dir=msgs-package
unzip -qq -d $msgs_package_dir $msgs_package_filename
mv $msgs_package_dir/**/* $msgs_package_dir
remove_empty_dir_after_extracting $msgs_package_dir 'MSGS-'
chmod_sh_files_recursively $msgs_package_dir
# TODO, verificar se existe variável de ambiente "JBOSS_HOME" setada
# TODO, verificar se a porta 8080 está sendo usada
find $msgs_package_dir -type f -name '*.sh' -exec chmod +x {} \;
WILDFLY_GEOSERVER_DIRNAME='wildfly-geoserver'
cd $root_dir
unzip -qq wildfly-15.0.0.Final.zip
wildfly15_folder="$root_dir/wildfly-15.0.0.Final"
WILDFLY_GEOSERVER_FILENAME_WC='wildfly-21*.zip'
WILDFLY_GEOSERVER_FILENAME=$(find . -maxdepth 1 -type f -name "$WILDFLY_GEOSERVER_FILENAME_WC")
unzip -d $WILDFLY_GEOSERVER_DIRNAME -qq $WILDFLY_GEOSERVER_FILENAME
remove_empty_dir_after_extracting $WILDFLY_GEOSERVER_DIRNAME 'wildfly-'
chmod_sh_files_recursively $WILDFLY_GEOSERVER_DIRNAME
# TODO, a partir daqui, Java 11 se MSGS = 4?
# TODO, portas 8080 e 9990 não podem estar em uso
$msgs_package_dir/appServerConfigurator/bin/setup.sh
# $msgs_package_dir/bin/setup.sh
find $msgs_package_dir -type f -name '*.sh' -exec chmod +x {} \;
cp $root_dir/server/shared/config/map_info.xml $root_dir/$msgs_package_dir/geoserverConfigurator/config
cp server/shared/config/map_info.xml $msgs_package_dir/geoserverConfigurator/config
mkdir --parents $wildfly15_folder/standalone/data_dir
mkdir --parents $WILDFLY_GEOSERVER_DIRNAME/standalone/data_dir
$msgs_package_dir/geoserverConfigurator/bin/setup.sh
unzip -qq -d $wildfly15_folder/standalone server/installation/deployments/mapserver/mapserver-geoserver-data_dir.zip
GEOSERVER_BIN_FILENAME=runstandalone.sh
# TODO, quebra aqui
unzip -qq -d $wildfly15_folder/standalone/data_dir/www/map $msgs_map_filename
if [ ! $NEOCAD_INSTALLATION ]; then
unzip -qq -d $WILDFLY_GEOSERVER_DIRNAME/standalone server/installation/deployments/mapserver/mapserver-geoserver-data_dir.zip
sed -i 's/8788/8789/g' $wildfly15_folder/bin/runstandalone.sh
# TODO, quebra aqui
unzip -qq -d $WILDFLY_GEOSERVER_DIRNAME/standalone/data_dir/www/map $msgs_map_filename
else
GEOSERVER_BIN_FILENAME=standalone.sh
fi
find $wildfly15_folder -type f -name '*.sh' -exec chmod +x {} \;
GEOSERVER_BIN=$WILDFLY_GEOSERVER_DIRNAME/bin/$GEOSERVER_BIN_FILENAME
sed -i 's/8788/8789/g' $GEOSERVER_BIN
find $WILDFLY_GEOSERVER_DIRNAME -type f -name '*.sh' -exec chmod +x {} \;
if $should_install_apache; then
sudo apt install apache2
@@ -311,11 +358,11 @@ if $should_install_apache; then
sudo a2enmod proxy_http
apache2conf_filepath='/etc/apache2/apache2.conf'
hostname_line="ServerName $hostname:8808"
hostname_line="ServerName $(hostname):8808"
if ! grep -q "$hostname_line" "$apache2conf_filepath"; then
if [ ! $(grep -q "$hostname_line" "$apache2conf_filepath") ]; then # TODO, sempre da true
echo "" | sudo tee --append $apache2conf_filepath
echo "ServerName $hostname:8808" | sudo tee --append $apache2conf_filepath
echo "$hostname_line" | sudo tee --append $apache2conf_filepath
fi
apache2portsconf_filepath='/etc/apache2/ports.conf'
@@ -328,6 +375,7 @@ if $should_install_apache; then
"ProxyPass /geoserver/ http://$hostname:8080/geoserver/"
"ProxyPassReverse /geoserver/ http://$hostname:8080/geoserver/")
# TODO, nao funciona
for line in "${text_to_add[@]}"; do
sudo sed -i '/<\/IfModule>/i '"\\ \\ \\ \\ \\ \\ \\ \\ $line" $apache2proxyconf_filepath
done