@@ -37,7 +37,11 @@ function other_starts() {
37
37
# $2 - the setting/property to set
38
38
# $3 - the new value
39
39
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"
41
45
}
42
46
43
47
# $1 - the setting/property to set
@@ -79,17 +83,18 @@ file_env() {
79
83
# $2 - the replacement text
80
84
# $3 - the file in which to do the search/replace
81
85
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"
83
91
}
84
92
85
93
# $1 - the config file name found in WEB-INF (e.g. "xwiki.cfg")
86
94
function saveConfigurationFile() {
87
95
if [ -f " /usr/local/xwiki/data/$1 " ]; then
88
96
echo " Reusing existing config file $1 ..."
89
97
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 "
93
98
fi
94
99
}
95
100
@@ -98,9 +103,6 @@ function restoreConfigurationFile() {
98
103
if [ -f " /usr/local/xwiki/data/$1 " ]; then
99
104
echo " Synchronizing config file $1 ..."
100
105
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 "
104
106
fi
105
107
}
106
108
@@ -146,9 +148,7 @@ function configure() {
146
148
xwiki_set_properties ' solr.remote.url' " http://$INDEX_HOST :$INDEX_PORT /solr/xwiki"
147
149
fi
148
150
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.
152
152
mkdir -p /usr/local/xwiki/data
153
153
saveConfigurationFile ' hibernate.cfg.xml'
154
154
saveConfigurationFile ' xwiki.cfg'
0 commit comments