Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: Solr remote url and properties settings #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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