janhoy commented on code in PR #3958:
URL: https://github.com/apache/solr/pull/3958#discussion_r2628859060


##########
solr/docker/scripts/init-var-solr:
##########
@@ -57,7 +57,8 @@ if [ ! -d "$DIR/logs" ]; then
 fi
 
 if [ ! -f "$DIR/log4j2.xml" ]; then
-    #echo "Copying log4j2.xml"
     cp -a /opt/solr/server/resources/log4j2.xml "$DIR/log4j2.xml"
+elif grep -q 'solr\.log\.dir' "$DIR/log4j2.xml"; then
+    [ -w "$DIR/log4j2.xml" ] && sed -i 's/solr\.log\.dir/solr.logs.dir/g' 
"$DIR/log4j2.xml" 2>/dev/null || echo "Warning: Could not migrate solr.log.dir 
to solr.logs.dir in $DIR/log4j2.xml" >&2

Review Comment:
   Patching existing log4j2.xml is done only if
   * there is a pre-existing file
   * that file contains the old pattern
   * The file is writable (not bind-mounted from a read-only fs)
   * Warns if `sed` failed
   
   Perhaps we should skip the `-w` test (file writable), and instead just 
attempt `sed -i`, the benefit would be that we  print the warning if the 
patching fails due to readonly mount. Or should perhaps the entire script fail 
in that case, as it evidently does if log4j2.xml does NOT pre-exist and the 
`cp` command on line 60 fails...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to