Skip to content

Commit

Permalink
XDOCKER-183: configure a remote Solr using
Browse files Browse the repository at this point in the history
  improve replace properties function
  change solr remote url

Signed-off-by: GridexX <[email protected]>
  • Loading branch information
GridexX committed Jul 17, 2023
1 parent d16b38d commit 8812f1e
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 33 deletions.
21 changes: 16 additions & 5 deletions 14/mariadb-tomcat/xwiki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ function other_starts() {
# $1 - the path to xwiki.[cfg|properties]
# $2 - the setting/property to set
# $3 - the new value
function xwiki_replace() {
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
function xwiki_replace_or_add() {
local file_path="$1"
local setting="$2"
local new_value="$3"

# Check if the setting exists in the file
if grep -Eq "^ *#? *$setting=" "$file_path"; then
# If the setting exists, replace the occurrence with the new value
sed -i 's|^\( *#\? *\)'"$setting"'=.*$|'"$setting"'='"$new_value"'|g' "$file_path"
else
# If the setting doesn't exist, add it at the end of the file
echo "$setting=$new_value" >> "$file_path"
fi
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_cfg() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_properties() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
}

# usage: file_env VAR [DEFAULT]
Expand Down Expand Up @@ -145,7 +156,7 @@ function configure() {
if [ $INDEX_HOST != 'localhost' ]; then
echo ' Configuring remote Solr Index'
xwiki_set_properties 'solr.type' 'remote'
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
xwiki_set_properties 'solr.remote.baseURL' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
fi

# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
Expand Down
21 changes: 16 additions & 5 deletions 14/mysql-tomcat/xwiki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ function other_starts() {
# $1 - the path to xwiki.[cfg|properties]
# $2 - the setting/property to set
# $3 - the new value
function xwiki_replace() {
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
function xwiki_replace_or_add() {
local file_path="$1"
local setting="$2"
local new_value="$3"

# Check if the setting exists in the file
if grep -Eq "^ *#? *$setting=" "$file_path"; then
# If the setting exists, replace the occurrence with the new value
sed -i 's|^\( *#\? *\)'"$setting"'=.*$|'"$setting"'='"$new_value"'|g' "$file_path"
else
# If the setting doesn't exist, add it at the end of the file
echo "$setting=$new_value" >> "$file_path"
fi
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_cfg() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_properties() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
}

# usage: file_env VAR [DEFAULT]
Expand Down Expand Up @@ -145,7 +156,7 @@ function configure() {
if [ $INDEX_HOST != 'localhost' ]; then
echo ' Configuring remote Solr Index'
xwiki_set_properties 'solr.type' 'remote'
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
xwiki_set_properties 'solr.remote.baseURL' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
fi

# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
Expand Down
21 changes: 16 additions & 5 deletions 14/postgres-tomcat/xwiki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ function other_starts() {
# $1 - the path to xwiki.[cfg|properties]
# $2 - the setting/property to set
# $3 - the new value
function xwiki_replace() {
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
function xwiki_replace_or_add() {
local file_path="$1"
local setting="$2"
local new_value="$3"

# Check if the setting exists in the file
if grep -Eq "^ *#? *$setting=" "$file_path"; then
# If the setting exists, replace the occurrence with the new value
sed -i 's|^\( *#\? *\)'"$setting"'=.*$|'"$setting"'='"$new_value"'|g' "$file_path"
else
# If the setting doesn't exist, add it at the end of the file
echo "$setting=$new_value" >> "$file_path"
fi
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_cfg() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_properties() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
}

# usage: file_env VAR [DEFAULT]
Expand Down Expand Up @@ -145,7 +156,7 @@ function configure() {
if [ $INDEX_HOST != 'localhost' ]; then
echo ' Configuring remote Solr Index'
xwiki_set_properties 'solr.type' 'remote'
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
xwiki_set_properties 'solr.remote.baseURL' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
fi

# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
Expand Down
21 changes: 16 additions & 5 deletions 15/mariadb-tomcat/xwiki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ function other_starts() {
# $1 - the path to xwiki.[cfg|properties]
# $2 - the setting/property to set
# $3 - the new value
function xwiki_replace() {
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
function xwiki_replace_or_add() {
local file_path="$1"
local setting="$2"
local new_value="$3"

# Check if the setting exists in the file
if grep -Eq "^ *#? *$setting=" "$file_path"; then
# If the setting exists, replace the occurrence with the new value
sed -i 's|^\( *#\? *\)'"$setting"'=.*$|'"$setting"'='"$new_value"'|g' "$file_path"
else
# If the setting doesn't exist, add it at the end of the file
echo "$setting=$new_value" >> "$file_path"
fi
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_cfg() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_properties() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
}

# usage: file_env VAR [DEFAULT]
Expand Down Expand Up @@ -145,7 +156,7 @@ function configure() {
if [ $INDEX_HOST != 'localhost' ]; then
echo ' Configuring remote Solr Index'
xwiki_set_properties 'solr.type' 'remote'
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
xwiki_set_properties 'solr.remote.baseURL' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
fi

# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
Expand Down
21 changes: 16 additions & 5 deletions 15/mysql-tomcat/xwiki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ function other_starts() {
# $1 - the path to xwiki.[cfg|properties]
# $2 - the setting/property to set
# $3 - the new value
function xwiki_replace() {
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
function xwiki_replace_or_add() {
local file_path="$1"
local setting="$2"
local new_value="$3"

# Check if the setting exists in the file
if grep -Eq "^ *#? *$setting=" "$file_path"; then
# If the setting exists, replace the occurrence with the new value
sed -i 's|^\( *#\? *\)'"$setting"'=.*$|'"$setting"'='"$new_value"'|g' "$file_path"
else
# If the setting doesn't exist, add it at the end of the file
echo "$setting=$new_value" >> "$file_path"
fi
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_cfg() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_properties() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
}

# usage: file_env VAR [DEFAULT]
Expand Down Expand Up @@ -145,7 +156,7 @@ function configure() {
if [ $INDEX_HOST != 'localhost' ]; then
echo ' Configuring remote Solr Index'
xwiki_set_properties 'solr.type' 'remote'
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
xwiki_set_properties 'solr.remote.baseURL' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
fi

# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
Expand Down
21 changes: 16 additions & 5 deletions 15/postgres-tomcat/xwiki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ function other_starts() {
# $1 - the path to xwiki.[cfg|properties]
# $2 - the setting/property to set
# $3 - the new value
function xwiki_replace() {
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
function xwiki_replace_or_add() {
local file_path="$1"
local setting="$2"
local new_value="$3"

# Check if the setting exists in the file
if grep -Eq "^ *#? *$setting=" "$file_path"; then
# If the setting exists, replace the occurrence with the new value
sed -i 's|^\( *#\? *\)'"$setting"'=.*$|'"$setting"'='"$new_value"'|g' "$file_path"
else
# If the setting doesn't exist, add it at the end of the file
echo "$setting=$new_value" >> "$file_path"
fi
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_cfg() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.cfg "$1" "$2"
}

# $1 - the setting/property to set
# $2 - the new value
function xwiki_set_properties() {
xwiki_replace /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
xwiki_replace_or_add /usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/xwiki.properties "$1" "$2"
}

# usage: file_env VAR [DEFAULT]
Expand Down Expand Up @@ -145,7 +156,7 @@ function configure() {
if [ $INDEX_HOST != 'localhost' ]; then
echo ' Configuring remote Solr Index'
xwiki_set_properties 'solr.type' 'remote'
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
xwiki_set_properties 'solr.remote.baseURL' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
fi

# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
Expand Down
17 changes: 14 additions & 3 deletions template/xwiki/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@ function other_starts() {
# \$1 - the path to xwiki.[cfg|properties]
# \$2 - the setting/property to set
# \$3 - the new value
function xwiki_replace() {
sed -i s~"\\#\\? \\?\$2 \\?=.*"~"\$2=\$3"~g "\$1"
function xwiki_replace_or_add() {
local file_path="$1"
local setting="$2"
local new_value="$3"

# Check if the setting exists in the file
if grep -Eq "^ *#? *$setting=" "$file_path"; then
# If the setting exists, replace the occurrence with the new value
sed -i 's|^\( *#\? *\)'"$setting"'=.*$|'"$setting"'='"$new_value"'|g' "$file_path"
else
# If the setting doesn't exist, add it at the end of the file
echo "$setting=$new_value" >> "$file_path"
fi
}

# \$1 - the setting/property to set
Expand Down Expand Up @@ -145,7 +156,7 @@ function configure() {
if [ \$INDEX_HOST != 'localhost' ]; then
echo ' Configuring remote Solr Index'
xwiki_set_properties 'solr.type' 'remote'
xwiki_set_properties 'solr.remote.url' "http://\$INDEX_HOST:\$INDEX_PORT/solr/xwiki"
xwiki_set_properties 'solr.remote.baseURL' "http://\$INDEX_HOST:\$INDEX_PORT/solr/xwiki"
fi

# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
Expand Down

0 comments on commit 8812f1e

Please sign in to comment.