Skip to content

Commit

Permalink
[tomcat] Stop installing sed
Browse files Browse the repository at this point in the history
We can perform the substitution without sed
Also, fix the path to the logging.properties, tomcat actually uses
/usr/share/tomcat/conf/logging.properties and ignores
/etc/tomcat/logging.properties
  • Loading branch information
dcermak committed Dec 11, 2024
1 parent 2f80397 commit fed3bdd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/bci_build/package/apache_tomcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ def _get_java_packages(jre_major: int) -> list[str]:
if tomcat_ver == _TOMCAT_VERSIONS[0]
else f"tomcat{tomcat_ver.partition('.')[0]}"
),
# currently needed by custom_end
"sed",
Package("util-linux", PackageType.DELETE),
]
+ _get_java_packages(jre_version),
Expand All @@ -120,11 +118,15 @@ def _get_java_packages(jre_major: int) -> list[str]:
},
custom_end=rf"""{DOCKERFILE_RUN} mkdir -p /var/log/tomcat; chown --recursive tomcat:tomcat /var/log/tomcat
{DOCKERFILE_RUN} ln -s {_CATALINA_HOME} /usr/local/tomcat
{DOCKERFILE_RUN} \
sed -i /etc/tomcat/logging.properties \
-e 's|org\.apache\.catalina\.core\.ContainerBase\.\[Catalina\]\.\[localhost\]\.handlers =.*|org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.ConsoleHandler|' \
-e 's|org\.apache\.catalina\.core\.ContainerBase\.\[Catalina\]\.\[localhost\]\.\[/manager\]\.handlers =.*|org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = java.util.logging.ConsoleHandler|' \
-e 's|org\.apache\.catalina\.core\.ContainerBase\.\[Catalina\]\.\[localhost\]\.\[/host-manager\]\.handlers =.*|org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = java.util.logging.ConsoleHandler|'
{DOCKERFILE_RUN} """
+ r"""while IFS= read -r line; do \
line=${line/org\.apache\.catalina\.core\.ContainerBase\.\[Catalina\]\.\[localhost\]\.handlers =*/org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.ConsoleHandler}; \
line=${line/org\.apache\.catalina\.core\.ContainerBase\.\[Catalina\]\.\[localhost\]\.\[\/manager\]\.handlers =*/org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = java.util.logging.ConsoleHandler}; \
line=${line/org\.apache\.catalina\.core\.ContainerBase\.\[Catalina\]\.\[localhost\]\.\[\/host-manager\]\.handlers =*/org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = java.util.logging.ConsoleHandler}; \
echo "$line" >> /tmp/logging.properties; \
done < /usr/share/tomcat/conf/logging.properties; \
mv /tmp/logging.properties /usr/share/tomcat/conf/logging.properties
WORKDIR $CATALINA_HOME
""",
Expand Down

0 comments on commit fed3bdd

Please sign in to comment.