File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,33 @@ if [ "$1" = configure ]; then
5959 chown -R cloud:cloud /usr/share/cloudstack-management/templates
6060 find /usr/share/cloudstack-management/templates -type d -exec chmod 0770 {} \;
6161
62+ LOGFILE=" ${CONFDIR} /log4j-cloud.xml"
63+
64+ # Detect if current file is old Log4j1 format
65+ if grep -q " <log4j:configuration" " $LOGFILE " 2> /dev/null; then
66+ echo " Old Log4j1 format detected in $LOGFILE "
67+
68+ BACKUP_SUFFIXES=" .rpmnew .dpkg-new .dpkg-dist"
69+ for sfx in $BACKUP_SUFFIXES ; do
70+ NEWFILE=" ${LOGFILE}${sfx} "
71+ if [ -f " $NEWFILE " ]; then
72+ echo " Found new version candidate: $NEWFILE "
73+
74+ # Verify that the candidate actually has Log4j2 syntax
75+ if grep -q " <Configuration" " $NEWFILE " 2> /dev/null; then
76+ echo " Verified Log4j2 format in $NEWFILE — applying update."
77+ cp -f " $NEWFILE " " $LOGFILE "
78+ mv " $NEWFILE " " ${NEWFILE} .bak.$( date +%F_%H-%M-%S) "
79+ echo " Replaced old Log4j1 config with Log4j2 version."
80+ break
81+ else
82+ echo " WARNING: $NEWFILE does not appear to be Log4j2 format — skipping."
83+ fi
84+ fi
85+ done
86+ else
87+ echo " Log4j2 format already present — no action needed."
88+ fi
6289 ln -sf ${CONFDIR} /log4j-cloud.xml ${CONFDIR} /log4j2.xml
6390
6491 # Add jdbc MySQL driver settings to db.properties if not present
Original file line number Diff line number Diff line change @@ -29,4 +29,14 @@ if [ "$1" = upgrade ]; then
2929 rm -f /usr/share/cloudstack-management/work
3030 rm -f /etc/default/cloudstack-management
3131 fi
32+
33+ if [ -L " /etc/cloudstack/management/log4j.xml" ]; then
34+ echo " Removing existing /etc/cloudstack/management/log4j.xml, symlink will again be created during post install"
35+ rm -f /etc/cloudstack/management/log4j.xml
36+ fi
37+
38+ if [ -L " /etc/cloudstack/management/log4j2.xml" ]; then
39+ echo " Removing existing /etc/cloudstack/management/log4j2.xml, symlink will again be created during post install"
40+ rm -f /etc/cloudstack/management/log4j2.xml
41+ fi
3242fi
You can’t perform that action at this time.
0 commit comments