Merge remote-tracking branch 'origin/feature/22955'

This commit is contained in:
Lucio Lelii 2023-04-04 11:48:11 +02:00
commit 650b23cfcc
10 changed files with 238 additions and 204 deletions

View File

@ -3,6 +3,7 @@
<name>smartgears-distribution</name>
<comment></comment>
<projects>
<project>common-service</project>
</projects>
<buildSpec>
<buildCommand>

View File

@ -2,34 +2,26 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for Smartgears Distribution
## [v3.5.0]
## [v4.0.0-SNAPSHOT] - 2022-03-30
- upgraded gcube-smartgears-bom
- new common-smartgears version
- added resource-registry-handlers to distribution
## [v3.4.7]
- upgraded gcube-smartgears-bom
- new common-smartgears version
## [v3.4.6] - 2022-04-20
- added roles to ExternalService Client
- moving to smartgears-4.0.0
## [v3.4.5] - 2022-03-29
- fixes issue [#23075]
## [v3.4.4] - 2022-03-23
- solved issue on policy check
## [v3.4.3] - 2022-01-19
- enabled policy check on smartgears
- container configuration for test added
## [v3.4.2] - 2021-11-08
- common-smartgrears library updated
@ -38,22 +30,27 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Released to have and up-to-date distribution
## [v3.4.0] - 2020-05-25
- Released to have and up-to-date distribution
## [v3.3.0]
- Accounting-lib inherited dependency has been upgraded to 4.1.0
## [v3.2.0]
- clean-container script uses proxy
## [v3.1.0]
- Upgraded gcube-smartgears-bom to version 2.1.0
## [v3.0.0] - 2020-11-11
- Switched JSON management to gcube-jackson [#19283]

View File

@ -1,12 +1,16 @@
FROM tomcat:8.5.47-jdk8-openjdk
ARG nexuspath
ARG filename
ARG version
FROM tomcat:9.0.65-jdk11-openjdk-buster
ARG filename=smartgears-distribution-4.0.0-SNAPSHOT
ARG version=4.0.0-SNAPSHOT
COPY ./target/$filename.tar.gz /smartgears-distro.tar.gz
WORKDIR /
RUN curl -k $nexuspath/$filename.tar.gz --output /smartgears-distro.tar.gz
RUN tar zxvf /smartgears-distro.tar.gz
RUN rm /smartgears-distro.tar.gz
RUN export CATALINA_HOME=/usr/local/tomcat
RUN ln -s /usr/local/tomcat tomcat
RUN mv smartgears-distribution-$version smartgears-distribution
ENV GHN_HOME=./smartgears-distribution
RUN ./smartgears-distribution/install -s tomcat
RUN ./smartgears-distribution/install -s tomcat
COPY startContainer.sh /startContainer.sh
RUN chmod +x /startContainer.sh
ENTRYPOINT ["/startContainer.sh"]
CMD ["catalina.sh","run"]

View File

@ -27,27 +27,29 @@ function showhelp {
}
while getopts ":d:s:g:a:xh" opt; do
case $opt in
d) distro=$OPTARG;;
s) shared=$OPTARG;;
g) ghnhome=$OPTARG;;
a) apps=$OPTARG;;
x) dryrun="true";;
h) showhelp
exit 0 ;;
:) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ;
showhelp;
echo -e "\naborting.\n"
exit 1;;
\?) echo -e "\nERROR:invalid option: -$OPTARG";
case $opt in
d) distro=$OPTARG;;
s) shared=$OPTARG;;
g) ghnhome=$OPTARG;;
a) apps=$OPTARG;;
x) dryrun="true";;
h) showhelp
exit 0 ;;
:) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ;
showhelp;
echo -e "\naborting.\n"
exit 1;;
\?) echo -e "\nERROR:invalid option: -$OPTARG";
showhelp;
echo -e "\naborting.\n"
exit 1 >&2 ;;
esac
esac
done
if [ -z "$ghnhome" ]; then
if [ -z "$GHN_HOME" ]; then
if [ -z "$ghnhome" ]
then
if [ -z "$GHN_HOME" ]
then
echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2
showhelp
echo -e "\naborting.\n"
@ -56,31 +58,37 @@ if [ -z "$ghnhome" ]; then
ghnhome=$GHN_HOME
fi
fi
if [ ! -d "$ghnhome" ]; then
if [ -z "$dryrun" ]; then
mkdir $ghnhome
if [ ! -d "$ghnhome" ]
then
if [ -z "$dryrun" ]
then
mkdir $ghnhome
fi
fi
#tomcat target
if [ "$shared" = "tomcat" ]; then
if [ -z "$CATALINA_HOME" ]; then
if [ -z "$WEB_CONTAINER_HOME" ] ; then
echo -e "\nERROR: both CATALINA_HOME and WEB_CONTAINER_HOME are undefined." >&2
showhelp
echo -e "\naborting.\n"
exit 1
else
CATALINA_HOME=$WEB_CONTAINER_HOME
fi
fi
if [ "$shared" = "tomcat" ]
then
if [ -z "$CATALINA_HOME" ]
then
if [ -z "$WEB_CONTAINER_HOME" ]
then
echo -e "\nERROR: both CATALINA_HOME and WEB_CONTAINER_HOME are undefined." >&2
showhelp
echo -e "\naborting.\n"
exit 1
else
CATALINA_HOME=$WEB_CONTAINER_HOME
fi
fi
shared=$CATALINA_HOME/lib
apps=$CATALINA_HOME/webapps
fi
#shared is set
if [ -z "$shared" ]; then
if [ -z "$shared" ]
then
echo -e "\nERROR: shared directory is undefined (-s)." >&2
showhelp
echo -e "\naborting.\n"
@ -88,25 +96,29 @@ if [ -z "$shared" ]; then
fi
#shared exists and is a directory
if [ ! -d "$shared" ]; then
if [ ! -d "$shared" ]
then
echo -e "\nERROR: shared folder does not exist or is not a directory, aborting." >&2
exit 1;
fi
#shared exists and is a directory
if [ ! -d "$apps" ]; then
if [ ! -d "$apps" ]
then
echo -e "\nERROR: apps folder does not exist or is not a directory, aborting." >&2
exit 1;
fi
#distrolibs exists and is a directory
if [ ! -d "$distrolibs" ]; then
if [ ! -d "$distrolibs" ]
then
echo -e "\nERROR: distro libs does not exist or is not a directory, aborting."
exit 1;
fi
#distroapps exists and is a directory
if [ ! -d "$distroapps" ]; then
if [ ! -d "$distroapps" ]
then
echo -e "\nERROR: distro apps does not exist or is not a directory, aborting."
exit 1;
fi
@ -119,127 +131,134 @@ echo -e " target app directory = $(cd $(dirname $apps); pwd)/$(basename $apps
shopt -s nullglob
#uninstall libraries
if [ -f $shared/$liblist ]; then
if [ -f $shared/$liblist ]
then
echo -e "\nuninstalling existing libraries \c"
while read line; do
if [ -z "$dryrun" ]; then
rm $shared/$line
while read line
do
if [ -z "$dryrun" ]
then
rm $shared/$line
fi
echo -n "."
sleep .01
done < $shared/$liblist
if [ -z "$dryrun" ]; then
rm $shared/$liblist
fi
echo -n "."
sleep .01
done < $shared/$liblist
if [ -z "$dryrun" ]
then
rm $shared/$liblist
fi
fi
#uninstall apps
if [ -f $shared/$applist ]; then
if [ -f $shared/$applist ]
then
echo -e "\nuninstalling existing apps \c"
while read line; do
if [ -z "$dryrun" ]; then
rm $apps/$line
folder=${line:0:-4}
if [ ! -z "$folder" ]; then
rm -rf $apps/$folder
fi
while read line
do
if [ -z "$dryrun" ]
then
rm $apps/$line
folder=${line:0:-4}
if [ ! -z "$folder" ]
then
rm -rf $apps/$folder
fi
fi
echo -n "."
sleep .01
done < $shared/$applist
if [ -z "$dryrun" ]; then
rm $shared/$applist
fi
echo -n "."
sleep .01
done < $shared/$applist
if [ -z "$dryrun" ]
then
rm $shared/$applist
fi
fi
#install libraries
echo -e "\ninstalling components \c"
for f in $distrolibs/*.*;
do
if [ -z "$dryrun" ]; then
cp $f $shared/
basename $f | sed -r 's/[0-9]{1,2}.[0-9]{1,2}(.[0-9]{1,2})?(-SNAPSHOT)?(-[0-9]{1,2}.[0-9]{1,2}(.[0-9]{1,2})?-[0-9]{4,8})?/*/' >> $shared/$liblist
fi
echo -n "."
sleep .01
done
do
if [ -z "$dryrun" ]
then
cp $f $shared/
basename $f | sed -r 's/[0-9]{1,2}.[0-9]{1,2}(.[0-9]{1,2})?(-SNAPSHOT)?(-[0-9]{1,2}.[0-9]{1,2}(.[0-9]{1,2})?-[0-9]{4,8})?/*/' >> $shared/$liblist
fi
echo -n "."
sleep .01
done
#install apps
echo -e "\ninstalling applications \c"
for f in $distroapps/*;
do
if [ -z "$dryrun" ]; then
cp $f $apps/
basename $f >> $shared/$applist
fi
echo -n "."
sleep .01
done
do
if [ -z "$dryrun" ]
then
cp $f $apps/
basename $f >> $shared/$applist
fi
echo -n "."
sleep .01
done
#install scripts
echo -e "\ninstalling scripts \c"
if [ ! -d "$ghnhome/scripts" ]; then
if [ -z "$dryrun" ]; then
mkdir $ghnhome/scripts
if [ ! -d "$ghnhome/scripts" ]
then
if [ -z "$dryrun" ]
then
mkdir $ghnhome/scripts
fi
fi
for f in $distroscripts/*;
do
if [ -z "$dryrun" ]; then
cp $f $ghnhome/scripts/
fi
do
if [ -z "$dryrun" ]
then
cp $f $ghnhome/scripts/
fi
echo -n "."
sleep .01
done
done
#install config
function escape_slashes {
sed 's/\//\\\//g'
sed 's/\//\\\//g'
}
function change_line {
local OLD_LINE_PATTERN=$1; shift
local NEW_LINE=$1; shift
local FILE=$1
local OLD_LINE_PATTERN=$1; shift
local NEW_LINE=$1; shift
local FILE=$1
local NEW=$(echo "${NEW_LINE}" | escape_slashes)
sed -i '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
local NEW=$(echo "${NEW_LINE}" | escape_slashes)
sed -i '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
}
function replace_property {
local PROPERTY=$1
#local OLD_LINE=$(sed -n "/${PROPERTY}/p" $ghnhome/container.xml)
local NEW_LINE=$(sed -n "/${PROPERTY}/p" $distro/container.xml)
#echo "Replacing property ${PROPERTY}:"
#echo $OLD_LINE
#echo $NEW_LINE
change_line "${PROPERTY}" "${NEW_LINE}" $ghnhome/container.xml
#echo "done."
local NEW_LINE=$(sed -n "/${PROPERTY}/p" $distro/container.ini)
change_line "${PROPERTY}" "${NEW_LINE}" $ghnhome/container.ini
}
echo -e "\ninstalling configuration \c"
if [ ! -s "$ghnhome/container.xml" ]; then
if [ -z "$dryrun" ]; then
cp $distro/container.xml $ghnhome/
if [ ! -s "$ghnhome/container.ini" ]
then
if [ -z "$dryrun" ]
then
cp $distro/container.ini $ghnhome/
fi
echo -n "."
sleep .01
sleep .01
else
if [ -z "$dryrun" ]; then
#echo "Creating a backup copy of $ghnhome/container.xml"
cp $ghnhome/container.xml $ghnhome/container.xml.bck
#echo "Creating a backup copy of $ghnhome/container.ini"
cp $ghnhome/container.ini $ghnhome/container.ini.bck
## Please note the ' at the end of SmartGearsDistribution property
## the ' is needed to exactly math the property otherwise also
@ -249,22 +268,27 @@ else
replace_property $property
done
fi
echo -n "."
sleep .01
sleep .01
fi
if [ -z "$dryrun" ]; then
cat $distro/logback.xml | sed "s|\${LOGFILE}|$ghnhome|" > $shared/logback.xml
echo -n "."
sleep .01
if [ -z "$dryrun" ]
then
cat $distro/logback.xml | sed "s|\${LOGFILE}|$ghnhome|" > $shared/logback.xml
echo -n "."
sleep .01
fi
#creating the symlink to shared and apps folder
if [ -z "$dryrun" ]; then
if [ -z "$dryrun" ]
then
ln -s $shared $ghnhome/lib
fi
if [ -z "$dryrun" ]; then
if [ -z "$dryrun" ]
then
ln -s $apps $ghnhome/apps
fi

View File

@ -1,4 +1,3 @@
<configuration scan="true" debug="false">
<appender name="FILE"

View File

@ -0,0 +1,41 @@
[node]
; mandatory
; optional fields: mode (=online), publicationFrequencyInSeconds (=60), authorizeChildrenContext (=false)
mode = offline
hostname = localhost
protocol = http
port = 8080
infrastructure = gcube
authorizeChildrenContext = true
publicationFrequencyInSeconds = 60
[properties]
; not mandatory
SmartGearsDistribution = ${project.version}
SmartGearsDistributionBundle = UnBundled
[site]
; mandatory
country = it
location = rome
;[proxy]
; not mandatory
;protocol = https
;hostname = proxy
;port = 80
[authorization]
; mandatory
; optional fields: provider factory (=org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory)
factory = org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory
factory.endpoint = https://accounts.dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token
credentials.class = org.gcube.smartgears.security.SimpleCredentials
credentials.clientID = testClient
credentials.secret = testSecret
;[persistence]
; not mandatory (default is LocalPersistence writing in the ghn home)
;class = utils.PersistenceWriterTest
;location = /tmp

View File

@ -1,41 +0,0 @@
<container mode='offline'>
<hostname>localhost</hostname>
<port>8080</port>
<infrastructure>gcube</infrastructure>
<!--
Add container tokens generated via portal for this host and port.
-->
<!--
<token>token1</token>
<token>token2</token>
-->
<!--
this tag enables authorize calls to this container also on VRE belonging to start tokens
-->
<!-- <authorizeChildrenContext>true</authorizeChildrenContext> -->
<site>
<country>it</country>
<location>rome</location>
<latitude>41.9000</latitude>
<longitude>12.5000</longitude>
</site>
<property name='SmartGearsDistribution' value='${project.version}' />
<property name='SmartGearsDistributionBundle' value='UnBundled' />
<!--
Add your own property value here. This values will be published on
GHN porfile in /Profile/GHNDescription/RunTimeEnv/ tag.
-->
<!--
<property name='prop1' value='val1' />
<property name='prop2' value='val2' />
-->
<publication-frequency>60</publication-frequency>
</container>

View File

@ -47,8 +47,8 @@
</fileSets>
<files>
<file>
<source>${distroDirectory}/contents/samplecontainer.xml</source>
<destName>container.xml</destName>
<source>${distroDirectory}/contents/samplecontainer.ini</source>
<destName>container.ini</destName>
<filtered>true</filtered>
</file>
</files>

42
pom.xml
View File

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -6,48 +7,39 @@
<groupId>org.gcube.tools</groupId>
<version>1.1.0</version>
</parent>
<groupId>org.gcube.distribution</groupId>
<artifactId>smartgears-distribution</artifactId>
<version>3.5.0</version>
<version>4.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>A distribution for the SmartGears Framework</name>
<properties>
<distroDirectory>distro</distroDirectory>
<wiki>https://wiki.gcube-system.org/gcube/SmartGears</wiki>
</properties>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>2.3.0</version>
<version>3.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears-utils</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>gxHTTP</artifactId>
<artifactId>gxHTTP</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
@ -88,22 +80,26 @@
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears</artifactId>
<version>[3.0.0,4.0.0-SNAPSHOT)</version>
<version>[4.0.0-SNAPSHOT,5.0.0-SNAPSHOT)</version>
<classifier>probe</classifier>
<type>war</type>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>whn-manager</artifactId>
<version>[2.0.0,3.0.0-SNAPSHOT)</version>
<type>war</type>
<groupId>org.gcube.common.core</groupId>
<artifactId>legacy-is-publisher-connector</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.gcube.data.transfer</groupId>
<artifactId>data-transfer-service</artifactId>
<version>[2.0.0,3.0.0-SNAPSHOT)</version>
<type>war</type>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>runtime</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.gcube.resourcemanagement</groupId>-->
<!-- <artifactId>whn-manager</artifactId>-->
<!-- <version>[3.0.0-SNAPSHOT,4.0.0-SNAPSHOT)</version>-->
<!-- <type>war</type>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
@ -142,8 +138,6 @@
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
<plugin>

15
startContainer.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
logs=/etc/logback.xml
container=/etc/container.ini
if [ -f "$logs" ]; then
cp $logs /tomcat/lib
fi
if [ -f "$container" ]; then
cp $container /smartgears-distribution
fi
exec "$@"