Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/8.1' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/8.1
  • Loading branch information
metaventis-build committed Dec 19, 2023
2 parents 6c3274b + e0ae353 commit 3a7e9c4
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@
# --- public url protocol
# SERVICES_RENDERING_SERVICE_PROT=http

# --- use dynamic url
# SERVICES_RENDERING_SERVICE_DYNAMIC_URL=false

# --- custom content url
# SERVICES_RENDERING_SERVICE_CUSTOM_CONTENT_URL=

# --- enables general data protection regulation
# SERVICES_RENDERING_SERVICE_GDPR_ENABLED=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ backup() {
$COMPOSE_EXEC pause repository-search-elastic-tracker repository-service || true
fi

if [[ -n $solr ]] ; then
if [[ -n $solr ]] ; then
echo "### backup solr4"
if [[ -n $compressed ]] ; then
docker run \
--rm \
--volumes-from "$(docker compose ps repository-search-solr4 -q)" \
--volumes-from "$($COMPOSE_EXEC ps repository-search-solr4 -q)" \
-v "$backupDir":/backup \
--network "$(docker inspect "$(docker compose ps repository-search-solr4 -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
--network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-solr4 -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
bitnami/minideb:bullseye \
bash -c '
check_Backup_status() {
Expand Down Expand Up @@ -241,9 +241,9 @@ backup() {
else
docker run \
--rm \
--volumes-from "$(docker compose ps repository-search-solr4 -q)" \
--volumes-from "$($COMPOSE_EXEC ps repository-search-solr4 -q)" \
-v "$backupDir":/backup/ \
--network "$(docker inspect "$(docker compose ps repository-search-solr4 -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
--network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-solr4 -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
bitnami/minideb:bullseye \
bash -c '
check_Backup_status() {
Expand Down Expand Up @@ -284,7 +284,7 @@ backup() {
docker run \
--rm \
-ti \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=http://repository-search-elastic-index:9200/workspace \
--output=$ \
Expand All @@ -297,7 +297,7 @@ backup() {
docker run \
--rm \
-ti \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=http://repository-search-elastic-index:9200/transactions \
--output=$ \
Expand All @@ -310,7 +310,7 @@ backup() {
docker run \
--rm \
-ti \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=http://repository-search-elastic-index:9200/workspace \
--output=/tmp/elastic_workspace.json || {
Expand All @@ -322,7 +322,7 @@ backup() {
docker run \
--rm \
-ti \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=http://repository-search-elastic-index:9200/transactions \
--output=/tmp/elastic_transactions.json || {
Expand All @@ -333,49 +333,31 @@ backup() {
fi
fi

if [[ -n $repodb ]] ; then
if [[ "$($COMPOSE_EXEC ps repository-mongo -a)" != "no such service: repository-mongo" ]]; then
echo "backup mongo"

if [[ -n $compressed ]] ; then
$COMPOSE_EXEC exec -t repository-mongo sh -c "mongodump --archive --gzip -u ${REPOSITORY_MONGO_ROOT_USER:-root} -p ${REPOSITORY_MONGO_ROOT_PASS:-root}" >"$backupDir/repository-mongo.gz" || {
rm -rf "$backupDir"
echo "ERROR on creating mongodb dump"
exit 1
}
else
$COMPOSE_EXEC exec -t repository-mongo sh -c "mongodump --archive -u ${REPOSITORY_MONGO_ROOT_USER:-root} -p ${REPOSITORY_MONGO_ROOT_PASS:-root}" >"$backupDir/repository-mongo.dump" || {
rm -rf "$backupDir"
echo "ERROR on creating mongodb dump"
exit 1
}
fi
fi

if [[ -n $repodb ]] ; then
echo "backup postgres"

if [[ -n $compressed ]] ; then
$COMPOSE_EXEC exec -t repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; pg_dumpall --clean -U postgres | gzip" >"$backupDir/repository-db.gz" || {
$COMPOSE_EXEC exec -t repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; pg_dump --format custom --no-owner --no-privileges ${REPOSITORY_DATABASE_NAME:-repository} | gzip" >"$backupDir/repository-db.gz" || {
rm -rf "$backupDir"
echo "ERROR on creating postgres dump"
exit 1
}
else
$COMPOSE_EXEC exec -t repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; pg_dumpall --clean -U postgres" > "$backupDir/repository-db.sql" || {
$COMPOSE_EXEC exec -t repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; pg_dump --format custom --no-owner --no-privileges ${REPOSITORY_DATABASE_NAME:-repository}" > "$backupDir/repository-db.sql" || {
rm -rf "$backupDir"
echo "ERROR on creating postgres dump"
exit 1
}
fi


fi

if [[ -n $repobinaries ]] ; then
echo "backup binaries"
if [[ -n $compressed ]] ; then
docker run \
--rm \
--volumes-from "$(docker compose ps repository-service -q -a)" \
--volumes-from "$($COMPOSE_EXEC ps repository-service -q -a)" \
-v "$backupDir":/backup \
bitnami/minideb:bullseye \
bash -c '
Expand All @@ -389,7 +371,7 @@ backup() {
else
docker run \
--rm \
--volumes-from "$(docker compose ps repository-service -q -a)" \
--volumes-from "$($COMPOSE_EXEC ps repository-service -q -a)" \
-v "$backupDir":/backup \
bitnami/minideb:bullseye \
bash -c '
Expand All @@ -402,7 +384,6 @@ backup() {
fi
fi


if [[ -z $hotBackup ]] ; then
echo "### unpause repository and elastic tracker services"
$COMPOSE_EXEC unpause repository-search-elastic-tracker repository-service
Expand Down Expand Up @@ -454,11 +435,12 @@ restore() {
$COMPOSE_EXEC stop $container

if [[ -n $repo ]] ; then
# restore binaries
if [[ -f "$backupDir/binaries.tar" ]] ; then
echo "### restore binaries"
docker run \
--rm \
--volumes-from "$(docker compose ps repository-service -q -a)" \
--volumes-from "$($COMPOSE_EXEC ps repository-service -q -a)" \
-v "$backupDir":/backup \
bitnami/minideb:bullseye \
bash -c '
Expand All @@ -471,7 +453,7 @@ restore() {
echo "### restore binaries"
docker run \
--rm \
--volumes-from "$(docker compose ps repository-service -q -a)" \
--volumes-from "$($COMPOSE_EXEC ps repository-service -q -a)" \
-v "$backupDir":/backup \
bitnami/minideb:bullseye \
bash -c '
Expand All @@ -482,12 +464,27 @@ restore() {
'
fi

if [[ -f "$backupDir/repository-db.gz" ]] ; then
echo "### restore postgres"
gunzip <"$backupDir/repository-db.gz" | $COMPOSE_EXEC exec -T repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; psql -U postgres"
elif [[ -f "$backupDir/repository-db.sql" ]]; then
echo "### restore postgres"
$COMPOSE_EXEC exec -T repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; psql -U postgres" < "$backupDir/repository-db.sql"
if [[ -f "$backupDir/repository-db.gz" ]] || [[ -f "$backupDir/repository-db.sql" ]]; then
if [[ -f "$backupDir/repository-db.gz" ]] ; then
gunzip <"$backupDir/repository-db.gz" | $COMPOSE_EXEC exec -T repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; pg_restore --username ${REPOSITORY_DATABASE_USER:-repository} --dbname ${REPOSITORY_DATABASE_NAME:-repository} --no-owner --no-privileges"
elif [[ -f "$backupDir/repository-db.sql" ]]; then
$COMPOSE_EXEC exec -T repository-database sh -c "export PGPASSWORD=${REPOSITORY_DATABASE_PASS:-repository}; pg_restore --username ${REPOSITORY_DATABASE_USER:-repository} --dbname ${REPOSITORY_DATABASE_NAME:-repository} --no-owner --no-privileges" < "$backupDir/repository-db.sql"
fi

echo "### reset solr4"
docker run \
--rm \
--volumes-from "$($COMPOSE_EXEC ps repository-search-solr4 -q -a)" \
bitnami/minideb:bullseye \
bash -c '
rm -rf /opt/alfresco/alf_data/solr4/index || true
rm -rf /opt/alfresco/alf_data/solr4/content || true
rm -rf /opt/alfresco/alf_data/solr4/model || true
'

echo "### reset elastic"
$COMPOSE_EXEC exec -T repository-search-elastic-index bash -c 'rm -rf /usr/share/elasticsearch/data/nodes || true' || true
fi

if [[ "$($COMPOSE_EXEC ps repository-mongo -a)" != "no such service: repository-mongo" ]]; then
Expand All @@ -505,7 +502,7 @@ restore() {
echo "### restore solr4"
docker run \
--rm \
--volumes-from "$(docker compose ps repository-search-solr4 -q -a)" \
--volumes-from "$($COMPOSE_EXEC ps repository-search-solr4 -q -a)" \
-v "$backupDir":/backup \
bitnami/minideb:bullseye \
bash -c '
Expand All @@ -532,11 +529,12 @@ restore() {
fi

if [[ -n $elastic ]] ; then
echo "backup elastic"
echo "restore elastic"

if [[ -f "$backupDir/elastic_workspace.gz" ]] ; then
docker run \
--rm \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=/tmp/elastic_workspace.gz \
--output=http://repository-search-elastic-index:9200/workspace \
Expand All @@ -545,7 +543,7 @@ restore() {
elif [[ -f "$backupDir/elastic_workspace.json" ]] ; then
docker run \
--rm \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=/tmp/elastic_workspace.json \
--output=http://repository-search-elastic-index:9200/workspace \
Expand All @@ -555,7 +553,7 @@ restore() {
if [[ -f "$backupDir/elastic_transactions.gz" ]] ; then
docker run \
--rm \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=/tmp/elastic_transactions.gz \
--output=http://repository-search-elastic-index:9200/transactions \
Expand All @@ -564,7 +562,7 @@ restore() {
elif [[ -f "$backupDir/elastic_transactions.json" ]]; then
docker run \
--rm \
-v "$backupDir":/tmp --network "$(docker inspect "$(docker compose ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
-v "$backupDir":/tmp --network "$(docker inspect "$($COMPOSE_EXEC ps repository-search-elastic-index -q -a)" -f '{{range $net,$v := .NetworkSettings.Networks}}{{printf "%s" $net}}{{end}}')" \
elasticdump/elasticsearch-dump \
--input=/tmp/elastic_transactions.json \
--output=http://repository-search-elastic-index:9200/transactions \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ my_port_external="${SERVICES_RENDERING_SERVICE_PORT_EXTERNAL:-9100}"
my_path_external="${SERVICES_RENDERING_SERVICE_PATH_EXTERNAL:-/esrender}"
my_base_external="${my_prot_external}://${my_host_external}:${my_port_external}${my_path_external}"

# used to configure dynamic domains based on the accessing domains
# used to configure dynamic domains based on the accessing domains

rendering_service_custom_content_url="${SERVICES_RENDERING_SERVICE_CUSTOM_CONTENT_URL:-}"
rendering_service_dynamic_url="${SERVICES_RENDERING_SERVICE_DYNAMIC_URL:-false}"

my_external_url="${my_base_external}"
if [[ "$rendering_service_dynamic_url" == "true" ]]; then
my_external_url="${my_prot_external}://'.(\$_SERVER['HTTP_X_FORWARDED_HOST'] ? \$_SERVER['HTTP_X_FORWARDED_HOST'] : \$_SERVER['HTTP_HOST']).':${my_port_external}${my_path_external}"
fi

my_prot_internal="${SERVICES_RENDERING_SERVICE_PROT_INTERNAL:-http}"
my_host_internal="${SERVICES_RENDERING_SERVICE_HOST_INTERNAL:-services-rendering-service}"
my_port_internal="${SERVICES_RENDERING_SERVICE_PORT_INTERNAL:-8080}"
Expand Down Expand Up @@ -70,7 +81,6 @@ rendering_video_threads="${SERVICES_RENDERING_VIDEO_THREADS:-"1"}"




### Wait ###############################################################################################################

[[ -n "${cache_host}" && -n "${cache_port}" ]] && {
Expand Down Expand Up @@ -149,7 +159,7 @@ if [[ ! -f "${RS_CACHE}/config/version.json" ]]; then
cat >/tmp/config.ini <<-EOF
[application]
; url for client requests (accessible from the internet)
application_url_client="${my_base_external}"
application_url_client="${my_external_url}"
; url for requests from repository
application_url_repository="${my_base_internal}"
; ip of the server
Expand Down Expand Up @@ -271,9 +281,14 @@ sed -i -r 's|\$dbuser.*|\$dbuser = "'"${rendering_database_user}"'";|' "${dbConf
sed -i -r 's|\$pwd.*|\$pwd = "'"${rendering_database_pass}"'";|' "${dbConf}"

systemConf="${RS_ROOT}/conf/system.conf.php"
sed -i -r 's|\$MC_URL = ['"'"'"].*|\$MC_URL = "'"${my_base_external}"'";|' "${systemConf}"
sed -i -r 's|\$MC_URL = ['"'"'"].*|\$MC_URL = '"'${my_external_url}'"';|' "${systemConf}"
sed -i -r 's|\$MC_DOCROOT.*|\$MC_DOCROOT = "'"${RS_ROOT}"'";|' "${systemConf}"
sed -i -r 's|\$CC_RENDER_PATH.*|\$CC_RENDER_PATH = "'"${RS_CACHE}/data"'";|' "${systemConf}"
sed -i -r 's|\$CUSTOM_CONTENT_URL =.*|\$CUSTOM_CONTENT_URL = '"'${rendering_service_custom_content_url}'"';|' "${systemConf}"
grep -q '$CUSTOM_CONTENT_URL' "${systemConf}" || echo '$CUSTOM_CONTENT_URL = '"'${rendering_service_custom_content_url}'"';' >> "${systemConf}"




[[ -n $my_gdpr_modules ]] && my_gdpr_modules="'${my_gdpr_modules//,/','}'"
sed -i -r 's|\$DATAPROTECTIONREGULATION_CONFIG.*|\$DATAPROTECTIONREGULATION_CONFIG = ["enabled" => '"${my_gdpr_enabled}"', "modules" => ['"${my_gdpr_modules}"'], "urls" => ['"${my_gdpr_urls}"']];|' "${systemConf}"
Expand Down Expand Up @@ -318,6 +333,7 @@ if [[ -n $my_plugins ]] ; then
fi

homeApp="${RS_ROOT}/conf/esmain/homeApplication.properties.xml"

xmlstarlet ed -L \
-u '/properties/entry[@key="scheme"]' -v "${my_prot_internal}" \
-u '/properties/entry[@key="host"]' -v "${my_host_internal}" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ services:
SERVICES_RENDERING_SERVICE_PORT_EXTERNAL: "${SERVICES_RENDERING_SERVICE_PORT:-9100}"
SERVICES_RENDERING_SERVICE_PATH_EXTERNAL: "${SERVICES_RENDERING_SERVICE_PATH:-/esrender}"
SERVICES_RENDERING_SERVICE_PORT_INTERNAL: "8080"
SERVICES_RENDERING_SERVICE_DYNAMIC_URL: "${SERVICES_RENDERING_SERVICE_DYNAMIC_URL:-false}"
SERVICES_RENDERING_SERVICE_CUSTOM_CONTENT_URL: "${SERVICES_RENDERING_SERVICE_CUSTOM_CONTENT_URL:-}"
SERVICES_RENDERING_SERVICE_PROXY_NONPROXYHOSTS: "${NON_PROXY_HOST:-}"
SERVICES_RENDERING_SERVICE_PROXY_HOST: "${PROXY_HOST:-}"
SERVICES_RENDERING_SERVICE_PROXY_PORT: "${PROXY_PORT:-}"
Expand Down

0 comments on commit 3a7e9c4

Please sign in to comment.