Blogs

Blogs

Change the startup ASCII art of your Liferay instance

A completely pointless but fun customization

UPDATE: The previous version of this blog implied modifying the portal-impl.jar, but as my friend Jorge Díaz pointed out in the comments:

"In order to override a resource of portal-impl.jar, it is not necessary to modify the jar file, just create all folder structure inside ROOT/WEB-INF/classes folder. Any file included in that folder will be read before than the original one of portal-impl.jar. In your example, just create a folder structure called com/ liferay /portal/events/dependencies inside tomcat-9.0.17/webapps/ROOT/WEB-INF/classes and create there the "startup.txt" file that will override original one."

The blog has been updated to reflect this easier approach.

Thanks Jorge!


If you’ve launched a Liferay instance (from 7.0 onwards), you may have noticed this cute ASCII logo in the logs:

Cool isn’t it?

Ever wondered if you can change it? Or maybe it bothers you? Maybe you wish that instead you could see a nice tropical island every time you start your server to remind you of the good times? Not that starting a Liferay server means having a bad time, of course…

Well, I’m here to answer all those questions you never asked yourself and to tell you that yes, you can change it!

Show me that art!

The file that contains the ASCII art is located inside the portal-impl.jar

{YOUR_LIFERAY_HOME}/tomcat-X.X.X/webapps/ROOT/WEB-INF/lib/portal-impl.jar

And the file is inside the jar, in the following location:

com/liferay/portal/events/dependencies/startup.txt

How to overwrite the ASCII art file

To change the art, the first thing you need to do is to stop the server. Then, recreate the same folder structure where the status.txt lives inside the jar but in the WEB-INF/classes folder of your Liferay installation:

{YOUR_LIFERAY_HOME}/tomcat-X.X.X/webapps/ROOT/WEB-INF/classes/com/liferay/portal/events/dependencies/

Then, you’ll need to create a startup.txt file and create your ASCII art inside. Once you’re done, restart the server, follow the log et voilà, you’ll see your custom art:

But what about Docker?

If you’re a Docker fan like me, you’ll probably wonder how to achieve this in the ephemeral world of containers. One of the cool things of Liferay’s official Docker images is that you can run scripts before server startup by mounting a volume and placing scripts there. We'll leverage this to update the startup.txt file before the actual startup.

The first step is to create a parent folder, and inside create two folders: scripts and files. In my example, my parent folder is C:/Ibai/Docker/lr-72- rundir ,and inside I've created both scripts and files:

Everything you drop into the “files” folder will be copied to the /opt/ liferayfolder inside the container, and every bash script you put inside the “scripts” folder will be run before server startup.

To change the ASCII art you’ll need to create the folder structure (with a parent folder, ascii " in my case) inside the “files” folder and put the startup.txt file inside, just like the previous example:

This will copy this file to the /opt/ liferay / ascii /com/ liferay /portal/events/dependencies folder inside the container (once you run the container).

The last step is to create a script that moves the startup.txt file we added on the files folder to its final destination inside the container:

#!/bin/bash
mv /opt/liferay/ascii/com/liferay/portal/events/dependencies/startup.txt /opt/liferay/tomcat-9.0.17/webapps/ROOT/WEB-INF/classes/com/liferay/portal/events/dependencies/

Pro-tip: check your line endings if you use Windows!

Then all is left to do is to run the Liferay image mounting the volume accordingly, in my example:

docker run -it -p 8080:8080 -v C:\Ibai\Docker\lr-72-rundir:/etc/liferay/mount liferay/portal:7.2.0-rc2

Alternate Reality: Custom Docker Image

I won’t go in details into how Docker works, but easier than relying on scripts is to create a custom Docker image, leveraging the FROM command in the Dockerfile

You’ll need to provide your startup.txt file alongside your custom Dockerfile, copy it to the image and run your custom image.

An example Dockerfile that modifies this file (I've put the startup.txt file in an ascii-art folder in the same folder as the Dockerfile):

FROM liferay/portal:7.2.0-rc2
COPY ascii-art/startup.txt /opt/liferay/tomcat/webapps/ROOT/WEB-INF/classes/com/liferay/portal/events/dependencies/startup.txt

Also take into account that the official Liferay Docker images aren’t particularly lightweight, and due to Docker’s layered approach they can grow heavy in size.

Run your image as you would normally do, and you should see your custom ASCII art on container startup.

So there you go, you can now go crazy customizing that ASCII art!

Hi Ibai, In order to override a resource of portal-impl.jar, it is not necessary to modify the jar file, just create all folder structure inside ROOT/WEB-INF/classes folder. Any file included in that folder will be read before than the original one of portal-impl.jar. In your example, just create a folder structure called com/liferay/portal/events/dependencies inside tomcat-9.0.17/webapps/ROOT/WEB-INF/classes and create there the "startup.txt" file that will override original one.