Skip to content

Commit cdae307

Browse files
committed
XDOCKER-329: Stop copying the XWiki configuration files to the permanent directory
1 parent 0ecfd00 commit cdae307

File tree

14 files changed

+201
-165
lines changed

14 files changed

+201
-165
lines changed

14/mariadb-tomcat/xwiki/docker-entrypoint.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function other_starts() {
3737
# $2 - the setting/property to set
3838
# $3 - the new value
3939
function xwiki_replace() {
40-
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
40+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
41+
# which makes it fail if you map the initial file as a Docker volume mount.
42+
sed s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" > "$1.old"
43+
cp "$1.old" "$1"
44+
rm "$1.old"
4145
}
4246

4347
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
7983
# $2 - the replacement text
8084
# $3 - the file in which to do the search/replace
8185
function safesed {
82-
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
86+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
87+
# which makes it fail if you map the initial file as a Docker volume mount.
88+
sed "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" "$3" > "$3.old"
89+
cp "$3.old" "$3"
90+
rm "$3.old"
8391
}
8492

8593
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
8694
function saveConfigurationFile() {
8795
if [ -f "/usr/local/xwiki/data/$1" ]; then
8896
echo " Reusing existing config file $1..."
8997
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
90-
else
91-
echo " Saving config file $1..."
92-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
9398
fi
9499
}
95100

@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98103
if [ -f "/usr/local/xwiki/data/$1" ]; then
99104
echo " Synchronizing config file $1..."
100105
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
101-
else
102-
echo " No config file $1 found, using default from container..."
103-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
104106
fi
105107
}
106108

@@ -146,9 +148,7 @@ function configure() {
146148
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
147149
fi
148150

149-
# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
150-
# files to the permanent directory so that they can be easily modified by the user. They'll be synced at the next
151-
# start.
151+
# If the files already exist then copy them to the XWiki's WEB-INF directory.
152152
mkdir -p /usr/local/xwiki/data
153153
saveConfigurationFile 'hibernate.cfg.xml'
154154
saveConfigurationFile 'xwiki.cfg'

14/mysql-tomcat/xwiki/docker-entrypoint.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function other_starts() {
3737
# $2 - the setting/property to set
3838
# $3 - the new value
3939
function xwiki_replace() {
40-
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
40+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
41+
# which makes it fail if you map the initial file as a Docker volume mount.
42+
sed s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" > "$1.old"
43+
cp "$1.old" "$1"
44+
rm "$1.old"
4145
}
4246

4347
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
7983
# $2 - the replacement text
8084
# $3 - the file in which to do the search/replace
8185
function safesed {
82-
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
86+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
87+
# which makes it fail if you map the initial file as a Docker volume mount.
88+
sed "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" "$3" > "$3.old"
89+
cp "$3.old" "$3"
90+
rm "$3.old"
8391
}
8492

8593
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
8694
function saveConfigurationFile() {
8795
if [ -f "/usr/local/xwiki/data/$1" ]; then
8896
echo " Reusing existing config file $1..."
8997
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
90-
else
91-
echo " Saving config file $1..."
92-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
9398
fi
9499
}
95100

@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98103
if [ -f "/usr/local/xwiki/data/$1" ]; then
99104
echo " Synchronizing config file $1..."
100105
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
101-
else
102-
echo " No config file $1 found, using default from container..."
103-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
104106
fi
105107
}
106108

@@ -146,9 +148,7 @@ function configure() {
146148
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
147149
fi
148150

149-
# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
150-
# files to the permanent directory so that they can be easily modified by the user. They'll be synced at the next
151-
# start.
151+
# If the files already exist then copy them to the XWiki's WEB-INF directory.
152152
mkdir -p /usr/local/xwiki/data
153153
saveConfigurationFile 'hibernate.cfg.xml'
154154
saveConfigurationFile 'xwiki.cfg'

14/postgres-tomcat/xwiki/docker-entrypoint.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function other_starts() {
3737
# $2 - the setting/property to set
3838
# $3 - the new value
3939
function xwiki_replace() {
40-
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
40+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
41+
# which makes it fail if you map the initial file as a Docker volume mount.
42+
sed s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" > "$1.old"
43+
cp "$1.old" "$1"
44+
rm "$1.old"
4145
}
4246

4347
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
7983
# $2 - the replacement text
8084
# $3 - the file in which to do the search/replace
8185
function safesed {
82-
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
86+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
87+
# which makes it fail if you map the initial file as a Docker volume mount.
88+
sed "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" "$3" > "$3.old"
89+
cp "$3.old" "$3"
90+
rm "$3.old"
8391
}
8492

8593
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
8694
function saveConfigurationFile() {
8795
if [ -f "/usr/local/xwiki/data/$1" ]; then
8896
echo " Reusing existing config file $1..."
8997
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
90-
else
91-
echo " Saving config file $1..."
92-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
9398
fi
9499
}
95100

@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98103
if [ -f "/usr/local/xwiki/data/$1" ]; then
99104
echo " Synchronizing config file $1..."
100105
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
101-
else
102-
echo " No config file $1 found, using default from container..."
103-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
104106
fi
105107
}
106108

@@ -143,9 +145,7 @@ function configure() {
143145
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
144146
fi
145147

146-
# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
147-
# files to the permanent directory so that they can be easily modified by the user. They'll be synced at the next
148-
# start.
148+
# If the files already exist then copy them to the XWiki's WEB-INF directory.
149149
mkdir -p /usr/local/xwiki/data
150150
saveConfigurationFile 'hibernate.cfg.xml'
151151
saveConfigurationFile 'xwiki.cfg'

15/mariadb-tomcat/xwiki/docker-entrypoint.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function other_starts() {
3737
# $2 - the setting/property to set
3838
# $3 - the new value
3939
function xwiki_replace() {
40-
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
40+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
41+
# which makes it fail if you map the initial file as a Docker volume mount.
42+
sed s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" > "$1.old"
43+
cp "$1.old" "$1"
44+
rm "$1.old"
4145
}
4246

4347
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
7983
# $2 - the replacement text
8084
# $3 - the file in which to do the search/replace
8185
function safesed {
82-
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
86+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
87+
# which makes it fail if you map the initial file as a Docker volume mount.
88+
sed "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" "$3" > "$3.old"
89+
cp "$3.old" "$3"
90+
rm "$3.old"
8391
}
8492

8593
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
8694
function saveConfigurationFile() {
8795
if [ -f "/usr/local/xwiki/data/$1" ]; then
8896
echo " Reusing existing config file $1..."
8997
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
90-
else
91-
echo " Saving config file $1..."
92-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
9398
fi
9499
}
95100

@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98103
if [ -f "/usr/local/xwiki/data/$1" ]; then
99104
echo " Synchronizing config file $1..."
100105
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
101-
else
102-
echo " No config file $1 found, using default from container..."
103-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
104106
fi
105107
}
106108

@@ -146,9 +148,7 @@ function configure() {
146148
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
147149
fi
148150

149-
# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
150-
# files to the permanent directory so that they can be easily modified by the user. They'll be synced at the next
151-
# start.
151+
# If the files already exist then copy them to the XWiki's WEB-INF directory.
152152
mkdir -p /usr/local/xwiki/data
153153
saveConfigurationFile 'hibernate.cfg.xml'
154154
saveConfigurationFile 'xwiki.cfg'

15/mysql-tomcat/xwiki/docker-entrypoint.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function other_starts() {
3737
# $2 - the setting/property to set
3838
# $3 - the new value
3939
function xwiki_replace() {
40-
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
40+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
41+
# which makes it fail if you map the initial file as a Docker volume mount.
42+
sed s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" > "$1.old"
43+
cp "$1.old" "$1"
44+
rm "$1.old"
4145
}
4246

4347
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
7983
# $2 - the replacement text
8084
# $3 - the file in which to do the search/replace
8185
function safesed {
82-
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
86+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
87+
# which makes it fail if you map the initial file as a Docker volume mount.
88+
sed "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" "$3" > "$3.old"
89+
cp "$3.old" "$3"
90+
rm "$3.old"
8391
}
8492

8593
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
8694
function saveConfigurationFile() {
8795
if [ -f "/usr/local/xwiki/data/$1" ]; then
8896
echo " Reusing existing config file $1..."
8997
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
90-
else
91-
echo " Saving config file $1..."
92-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
9398
fi
9499
}
95100

@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98103
if [ -f "/usr/local/xwiki/data/$1" ]; then
99104
echo " Synchronizing config file $1..."
100105
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
101-
else
102-
echo " No config file $1 found, using default from container..."
103-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
104106
fi
105107
}
106108

@@ -146,9 +148,7 @@ function configure() {
146148
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
147149
fi
148150

149-
# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
150-
# files to the permanent directory so that they can be easily modified by the user. They'll be synced at the next
151-
# start.
151+
# If the files already exist then copy them to the XWiki's WEB-INF directory.
152152
mkdir -p /usr/local/xwiki/data
153153
saveConfigurationFile 'hibernate.cfg.xml'
154154
saveConfigurationFile 'xwiki.cfg'

15/postgres-tomcat/xwiki/docker-entrypoint.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function other_starts() {
3737
# $2 - the setting/property to set
3838
# $3 - the new value
3939
function xwiki_replace() {
40-
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
40+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
41+
# which makes it fail if you map the initial file as a Docker volume mount.
42+
sed s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" > "$1.old"
43+
cp "$1.old" "$1"
44+
rm "$1.old"
4145
}
4246

4347
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
7983
# $2 - the replacement text
8084
# $3 - the file in which to do the search/replace
8185
function safesed {
82-
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
86+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
87+
# which makes it fail if you map the initial file as a Docker volume mount.
88+
sed "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" "$3" > "$3.old"
89+
cp "$3.old" "$3"
90+
rm "$3.old"
8391
}
8492

8593
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
8694
function saveConfigurationFile() {
8795
if [ -f "/usr/local/xwiki/data/$1" ]; then
8896
echo " Reusing existing config file $1..."
8997
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
90-
else
91-
echo " Saving config file $1..."
92-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
9398
fi
9499
}
95100

@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98103
if [ -f "/usr/local/xwiki/data/$1" ]; then
99104
echo " Synchronizing config file $1..."
100105
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
101-
else
102-
echo " No config file $1 found, using default from container..."
103-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
104106
fi
105107
}
106108

@@ -143,9 +145,7 @@ function configure() {
143145
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
144146
fi
145147

146-
# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
147-
# files to the permanent directory so that they can be easily modified by the user. They'll be synced at the next
148-
# start.
148+
# If the files already exist then copy them to the XWiki's WEB-INF directory.
149149
mkdir -p /usr/local/xwiki/data
150150
saveConfigurationFile 'hibernate.cfg.xml'
151151
saveConfigurationFile 'xwiki.cfg'

16.4/mariadb-tomcat/xwiki/docker-entrypoint.sh

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function other_starts() {
3737
# $2 - the setting/property to set
3838
# $3 - the new value
3939
function xwiki_replace() {
40-
sed -i s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1"
40+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
41+
# which makes it fail if you map the initial file as a Docker volume mount.
42+
sed s~"\#\? \?$2 \?=.*"~"$2=$3"~g "$1" > "$1.old"
43+
cp "$1.old" "$1"
44+
rm "$1.old"
4145
}
4246

4347
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
7983
# $2 - the replacement text
8084
# $3 - the file in which to do the search/replace
8185
function safesed {
82-
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
86+
# Don't use "sed -i" as it creates a temporary file and perform a rename (thus changing the inode of the initial file)
87+
# which makes it fail if you map the initial file as a Docker volume mount.
88+
sed "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" "$3" > "$3.old"
89+
cp "$3.old" "$3"
90+
rm "$3.old"
8391
}
8492

8593
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
8694
function saveConfigurationFile() {
8795
if [ -f "/usr/local/xwiki/data/$1" ]; then
8896
echo " Reusing existing config file $1..."
8997
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
90-
else
91-
echo " Saving config file $1..."
92-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
9398
fi
9499
}
95100

@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98103
if [ -f "/usr/local/xwiki/data/$1" ]; then
99104
echo " Synchronizing config file $1..."
100105
cp "/usr/local/xwiki/data/$1" "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1"
101-
else
102-
echo " No config file $1 found, using default from container..."
103-
cp "/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF/$1" "/usr/local/xwiki/data/$1"
104106
fi
105107
}
106108

@@ -146,9 +148,7 @@ function configure() {
146148
xwiki_set_properties 'solr.remote.url' "http://$INDEX_HOST:$INDEX_PORT/solr/xwiki"
147149
fi
148150

149-
# If the files already exist then copy them to the XWiki's WEB-INF directory. Otherwise copy the default config
150-
# files to the permanent directory so that they can be easily modified by the user. They'll be synced at the next
151-
# start.
151+
# If the files already exist then copy them to the XWiki's WEB-INF directory.
152152
mkdir -p /usr/local/xwiki/data
153153
saveConfigurationFile 'hibernate.cfg.xml'
154154
saveConfigurationFile 'xwiki.cfg'

0 commit comments

Comments
 (0)