Multiple refactors and development on scripts/shell/job/gp folder
This commit is contained in:
10
scripts/shell/job/gp/disable-dbversion-check-on-software-info-file.sh
Executable file
10
scripts/shell/job/gp/disable-dbversion-check-on-software-info-file.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
filename='software-info.xml'
|
||||
|
||||
if [ ! -f "$filename" ]; then
|
||||
echo "Could not find the file \"$filename\" in the current directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
xmlstarlet ed --inplace --update '//attribute[@name="version"]' --value "." $filename
|
||||
66
scripts/shell/job/gp/explode-java-files.sh
Executable file
66
scripts/shell/job/gp/explode-java-files.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
show_help() {
|
||||
echo "Usage: $0 [--files|-f files]"
|
||||
echo "Options:"
|
||||
echo " --help | -h (Optional) Display help information on how to use this script"
|
||||
echo " --files | -f (Optional) Specify the files to explode, separation by comma (,)"
|
||||
echo " If not specified, the script will apply the changes to all [jew]ar files in current directory"
|
||||
echo " --revert true | -r true (Optional) Undo the exploding of java files"
|
||||
}
|
||||
|
||||
files_arg=''
|
||||
revert=false
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--help|-h) show_help; exit ;;
|
||||
--files|-f) files_arg="$2"; shift 2;;
|
||||
--revert|-r) revert=true; shift 2;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
convert_csv_to_array() {
|
||||
csv_arg=$1
|
||||
res_arr=`echo $csv_arg | tr ',' "\n"`
|
||||
echo $res_arr
|
||||
}
|
||||
|
||||
files=()
|
||||
|
||||
if [ ! -z "$files_arg" ]; then
|
||||
files=`convert_csv_to_array "$files_arg"`
|
||||
else
|
||||
regex_search=".*[jew]ar"
|
||||
|
||||
if $revert; then
|
||||
regex_search+=".old"
|
||||
fi
|
||||
|
||||
files=(`find * -maxdepth 0 -type f -regextype sed -regex $regex_search`)
|
||||
fi
|
||||
|
||||
for f in ${files[@]}; do
|
||||
if [ ! -f "$f" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if $revert; then
|
||||
file_without_old_suffix=${f%".old"}
|
||||
|
||||
# "f" will have ".old" suffix
|
||||
mv $f $file_without_old_suffix
|
||||
zip $file_without_old_suffix $f
|
||||
rm -f "$file_without_old_suffix.dodeploy"
|
||||
else
|
||||
mv $f $f.old
|
||||
unzip -d $f $f.old
|
||||
touch $f.dodeploy
|
||||
fi
|
||||
|
||||
rm -f "$f.isdeploying"
|
||||
rm -f "$f.deployed"
|
||||
rm -f "$f.failed"
|
||||
done
|
||||
146
scripts/shell/job/gp/install-gp.sh
Executable file
146
scripts/shell/job/gp/install-gp.sh
Executable file
@@ -0,0 +1,146 @@
|
||||
#!/bin/bash
|
||||
|
||||
show_help() {
|
||||
echo "Usage: $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 true (Optional) Make the script not download the files from Artifactory"
|
||||
}
|
||||
|
||||
version=''
|
||||
should_download=true
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--help|-h) show_help; exit ;;
|
||||
--version|-v) version="$2"; shift 2;;
|
||||
--no-download|--no-dl) should_download=false; shift 2;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
root_dir=`pwd`
|
||||
scripts_folder=$HOME/repos/personal/personal-devboot/scripts/shell/job/gp
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
echo "You must specify the package version!"
|
||||
echo "Example: `basename "$0"` --version 12.0.0.0.0-SNAPSHOT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$scripts_folder" ]; then
|
||||
echo "The git repository \"CloudAlb/personal-devboot\" must be in the \"~/repos\" folder!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
validate_repo_script() {
|
||||
script_filename=$1
|
||||
|
||||
if [ ! -f "$scripts_folder/$script_filename" ];then
|
||||
echo "The git repository \"CloudAlb/personal-devboot\" must have the script \"scripts/shell/job/gp/$script_filename\"!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
script_explode_java_files_filename='explode-java-files.sh'
|
||||
validate_repo_script $script_explode_java_files_filename
|
||||
|
||||
script_disable_dbversion_check_filename='disable-dbversion-check-on-software-info-file.sh'
|
||||
validate_repo_script $script_disable_dbversion_check_filename
|
||||
|
||||
root_dir=`pwd`
|
||||
|
||||
# download files
|
||||
|
||||
if $should_download; then
|
||||
base_url='artifactory.cpqd.com.br/artifactory'
|
||||
artifactory_repo='oss-package-dev'
|
||||
|
||||
if [[ $root_dir != *$version ]]; then
|
||||
mkdir $version
|
||||
cd $version
|
||||
root_dir=`pwd`
|
||||
fi
|
||||
|
||||
if [[ ${version} != *"-"* ]];then
|
||||
artifactory_repo='oss-package-rel'
|
||||
fi
|
||||
|
||||
all_files=(`jf rt search --sort-by=path "${artifactory_repo}/gp/${version}/*" | jq -r '.[].path'`)
|
||||
|
||||
for pkg in "${all_files[@]}"; do
|
||||
filename=`basename $pkg`
|
||||
|
||||
if [[ $filename == "cpqd-etics-configurator-appserver-wildfly"* ]] || \
|
||||
[[ $filename == "cpqd-dbmanager-etics-package"* ]] || \
|
||||
[[ $filename == "cpqd-dbmanager-customer"* ]] || \
|
||||
[[ $filename == "cpqd-etics-package-server"* ]] || \
|
||||
[[ $filename == "cpqd-etics-customer"* ]]; then
|
||||
|
||||
wget $base_url/$pkg
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
find * -maxdepth 0 -type d -exec sudo rm -rf {} \;
|
||||
|
||||
# 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/* .
|
||||
|
||||
# creating folders
|
||||
mkdir -p cpqd-folders/audit cpqd-folders/exportacoes cpqd-folders/updater cpqd-folders/dataloader cpqd-folders/virtualdisk
|
||||
|
||||
# unpacking files
|
||||
unzip wildfly-8.2.1.zip
|
||||
find wildfly-8.2.1 -type f -name '*.sh' -exec chmod +x {} \;
|
||||
|
||||
unzip -d wildfly-configurator cpqd-etics-configurator-appserver-wildfly*
|
||||
chmod +x wildfly-configurator/configurator/bin/setup.sh
|
||||
|
||||
wildfly-configurator/configurator/bin/setup.sh
|
||||
|
||||
# doing this again to add permissions for newly created files by configurator
|
||||
find wildfly-8.2.1 -type f -name '*.sh' -exec chmod +x {} \;
|
||||
|
||||
unzip -d server cpqd-etics-package-server*
|
||||
mv server/cpqd*/* server/
|
||||
rmdir server/cpqd*
|
||||
unzip -o -d server cpqd-dbmanager-etics-package*
|
||||
unzip -o -d server cpqd-dbmanager-customer*
|
||||
unzip -o -d server cpqd-etics-customer-*-package-server*
|
||||
|
||||
cd server/dbmanager
|
||||
./dbmanager.sh &
|
||||
|
||||
dbmanager_pid=`echo $!`
|
||||
wait $dbmanager_pid
|
||||
|
||||
cd $root_dir/server/configurator/bin
|
||||
chmod +x setup.sh
|
||||
./setup.sh
|
||||
|
||||
# TODO, depois daqui não executou
|
||||
|
||||
deployments_folder=$root_dir/wildfly-8.2.1/ports-01/deployments
|
||||
|
||||
# adding servergroupname
|
||||
cd $deployments_folder
|
||||
$scripts_folder/$script_explode_java_files_filename
|
||||
|
||||
hostname=`cat /etc/hostname`
|
||||
|
||||
cd $deployments_folder/../configuration
|
||||
|
||||
cp standalone-full.xml standalone-full.xml.old
|
||||
|
||||
xmlstarlet ed -L -N x="urn:jboss:domain:2.2" -s "//x:server/x:system-properties" -t elem -n property -v "" \
|
||||
-i "//x:server/x:system-properties/property[last()]" -t attr -n name -v "servergroupname" \
|
||||
-i "//x:server/x:system-properties/property[last()]" -t attr -n value -v "$hostname" standalone-full.xml
|
||||
|
||||
# adding ignore database version
|
||||
cd $deployments_folder/cpqd-configuration.jar
|
||||
|
||||
cp software-info.xml software-info.xml.old
|
||||
|
||||
$scripts_folder/$script_disable_dbversion_check_filename
|
||||
3
scripts/shell/job/gp/remove-all-files-old-extension.sh
Executable file
3
scripts/shell/job/gp/remove-all-files-old-extension.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
for i in *.old; do mv $i ${i%".old"}; done
|
||||
253
scripts/shell/job/gp/team-pipeline-local.sh
Executable file
253
scripts/shell/job/gp/team-pipeline-local.sh
Executable file
@@ -0,0 +1,253 @@
|
||||
#!/bin/bash
|
||||
|
||||
show_help() {
|
||||
echo "Usage: $0 [--commit-hashes|-c commit hashes] [--deployments-path|-d deployments path]"
|
||||
echo "Options:"
|
||||
echo " --help | -h (Optional) Display help information on how to use this script"
|
||||
echo " --commit-hashes | -c (Required) Specify the commit hashes, separation by comma (,)"
|
||||
echo " --repo-dir | -r (Required) Specify the git repository path that contains the commits"
|
||||
echo " --deployments-path | -d (Required) Specify the Wildfly ports-XX/deployments path"
|
||||
echo " --file-paths | -f (Optional) Specify file paths to consider in the update, separation by comma (,)"
|
||||
echo " Specifying this will make the \"--commit-hashes\" parameter optional"
|
||||
echo " --build | -b (Optional) If selected, the script will build the maven components in order to generate the target/ folder"
|
||||
echo " --use-git-status | -g (Optional) Will add the files with differences from the \"git status\" command"
|
||||
}
|
||||
|
||||
commit_hashes_arg=''
|
||||
repo_dir=''
|
||||
deployments_path=''
|
||||
file_paths_arg=''
|
||||
build_maven=false
|
||||
use_git_status=false
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--help|-h) show_help; exit ;;
|
||||
--repo-dir|-r) repo_dir="$2"; shift 2;;
|
||||
--commit-hashes|-c) commit_hashes_arg="$2"; shift 2;;
|
||||
--deployments-path|-d) deployments_path="$2"; shift 2;;
|
||||
--file-paths|-f) file_paths_arg="$2"; shift 2;;
|
||||
--build|-b) build_maven=true; shift 2;;
|
||||
--use-git-status|-g) use_git_status=true; shift 2;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# echo "commit_hashes_arg: $commit_hashes_arg"
|
||||
# echo "repo_dir: $repo_dir"
|
||||
# echo "deployments_path: $deployments_path"
|
||||
# echo "file_paths_arg: $file_paths_arg"
|
||||
# echo "build_maven: $build_maven"
|
||||
# echo "use_git_status: $use_git_status"
|
||||
|
||||
print_newline() {
|
||||
echo -e ""
|
||||
}
|
||||
|
||||
convert_csv_to_array() {
|
||||
csv_arg=$1
|
||||
res_arr=`echo $csv_arg | tr ',' "\n"`
|
||||
echo $res_arr
|
||||
}
|
||||
|
||||
commit_exists() {
|
||||
commit_hash=$1
|
||||
|
||||
if git cat-file -t $commit_hash; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
find_pom_xml_file_recursively() {
|
||||
path=$1
|
||||
|
||||
pom_path=`dirname $path`/pom.xml
|
||||
|
||||
if [ $pom_path == './pom.xml' ]; then
|
||||
# echo "Could not find a pom.xml file for a module"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $pom_path ]; then
|
||||
new_dir=`dirname $path`
|
||||
pom_path=`find_pom_xml_file_recursively $new_dir`
|
||||
fi
|
||||
|
||||
echo $pom_path
|
||||
}
|
||||
|
||||
arr_uniq() {
|
||||
arr=$1
|
||||
|
||||
echo $(for i in "${arr[@]}"; do echo $i; done | sort -u)
|
||||
}
|
||||
|
||||
build_mvn() {
|
||||
mvn clean install --file ./pom.xml --settings ~/.m2/settings.xml
|
||||
}
|
||||
|
||||
function join_by {
|
||||
local d=${1-} f=${2-}
|
||||
|
||||
if shift 2; then
|
||||
printf %s "$f" "${@/#/$d}"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_suffix() {
|
||||
local input="$1"
|
||||
local delimiter="-"
|
||||
local count=$(grep -o "${delimiter}" <<< "$input" | wc -l)
|
||||
local index=$(( count - 1 ))
|
||||
local result=$(cut -d"${delimiter}" -f1-"$index" <<< "$input")
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
get_substring_after_string() {
|
||||
str=$1
|
||||
subs=$2
|
||||
|
||||
echo ${str#*$subs}
|
||||
}
|
||||
|
||||
if [ -z "$file_paths_arg" ] \
|
||||
&& [ -z "$commit_hashes_arg" ] \
|
||||
&& ! $use_git_status; then
|
||||
echo "Error: Either one of these arguments should be provided:"
|
||||
echo " Commit hashes (--commit-hashes or -c) or;"
|
||||
echo " File paths (--file-paths or -f) or;"
|
||||
echo " Use Git Status (--use-git-status or -g)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -z "$commit_hashes_arg" ] && [ -z "$repo_dir" ]; then
|
||||
echo "Error: If you specify the Commit hashes (--commit-hashes or -c), the repository directory (--repo-dir or -r) is also required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$deployments_path" ]; then
|
||||
echo "Error: Deployments path (--deployments-path or -d) is required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
scripts_folder=$HOME/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!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cur=`pwd`
|
||||
|
||||
target_paths=()
|
||||
|
||||
cd $repo_dir
|
||||
if [ ! -z "$commit_hashes_arg" ]; then
|
||||
commit_hashes=`convert_csv_to_array "$commit_hashes_arg"`
|
||||
|
||||
for c in ${commit_hashes[@]}; do
|
||||
if ! commit_exists $c; then
|
||||
continue
|
||||
fi
|
||||
|
||||
target_paths+=(`git show --oneline --name-only $c | tail -n +2`)
|
||||
done
|
||||
fi
|
||||
|
||||
if $use_git_status; then
|
||||
target_paths+=(`git ls-files --modified`)
|
||||
fi
|
||||
|
||||
cd $cur
|
||||
|
||||
dot_java_files=()
|
||||
|
||||
if [ ! -z "$file_paths_arg" ]; then
|
||||
file_paths=`convert_csv_to_array "$file_paths_arg"`
|
||||
|
||||
if [ ! -f $f ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
target_paths+=("$f")
|
||||
fi
|
||||
|
||||
cd $repo_dir
|
||||
|
||||
for f in ${target_paths[@]}; do
|
||||
if [[ $f == *.java ]]; then
|
||||
dot_java_files+=(`basename $f`)
|
||||
fi
|
||||
done
|
||||
|
||||
target_paths_uniq=($(printf "%s\n" `dirname ${target_paths[@]}` | sort -u))
|
||||
|
||||
pom_paths=()
|
||||
|
||||
for i in ${target_paths_uniq[@]}; do
|
||||
res=`find_pom_xml_file_recursively $i`;
|
||||
pom_paths+=("$res")
|
||||
done
|
||||
|
||||
for p in ${pom_paths[@]}; do
|
||||
pom_dir=`dirname $p`
|
||||
cd $repo_dir/$pom_dir
|
||||
|
||||
[ $build_maven == true ] && build_mvn
|
||||
done
|
||||
|
||||
non_root_deployments_files_to_explode=()
|
||||
non_root_deployments_files_to_explode_full_path=()
|
||||
|
||||
for p in ${pom_paths[@]}; do
|
||||
pom_dir=$repo_dir/`dirname $p`
|
||||
|
||||
if [ ! -d "$pom_dir/target" ]; then
|
||||
echo "INFO: could not find the \"target\" folder in \"$pom_dir\""
|
||||
echo "INFO: initializing maven compilation..."
|
||||
|
||||
cd $pom_dir
|
||||
build_mvn
|
||||
fi
|
||||
|
||||
cd $pom_dir/target
|
||||
non_root_deployments_files_to_explode=`find * -maxdepth 0 -type f -regextype sed -regex ".*[jew]ar" ! -name '*-client.jar' ! -name '*-sources.jar'`
|
||||
done
|
||||
|
||||
cd $deployments_path
|
||||
root_deployments_files_to_explode=`find * -maxdepth 0 -type f -regextype sed -regex ".*[jew]ar"`
|
||||
|
||||
if [ ! -z "$root_deployments_files_to_explode" ]; then
|
||||
$scripts_folder/explode-java-files.sh --files `join_by , ${root_deployments_files_to_explode}` # webdeskmapreport, etc.
|
||||
fi
|
||||
|
||||
for f in ${non_root_deployments_files_to_explode[@]}; do
|
||||
f_prefix=`remove_suffix "$f"`
|
||||
file_path=`find * -maxdepth 1 -type f -name "$f_prefix*.jar"`
|
||||
|
||||
non_root_deployments_files_to_explode_full_path+=("$file_path")
|
||||
done
|
||||
|
||||
if [ ! -z "$non_root_deployments_files_to_explode_full_path"]; then
|
||||
$scripts_folder/explode-java-files.sh --files `join_by , ${non_root_deployments_files_to_explode_full_path}` # **/cpqd-geo-renderer-ejb, etc.
|
||||
fi
|
||||
|
||||
substring_path_cons="br/com/cpqd"
|
||||
|
||||
for f in ${dot_java_files[@]}; do
|
||||
class_file=${f%".java"}.class
|
||||
|
||||
class_file_paths=`find * -type f -name "$class_file"`
|
||||
|
||||
class_path_in_target=''
|
||||
for p in ${class_file_paths}; do
|
||||
substring_path=$substring_path_cons`get_substring_after_string "$p" "$substring_path_cons"`
|
||||
class_path_in_target=`find $repo_dir -type f -wholename "**/${substring_path}"`
|
||||
done
|
||||
|
||||
for p in ${class_file_paths[@]}; do
|
||||
cp --force $class_path_in_target `dirname $p`
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user