// Module included in the following assemblies:
//
// * openshift_images/using_images/customizing-s2i-images.adoc

:_mod-docs-content-type: PROCEDURE
[id="images-using-customizing-s2i-images-scripts-embedded_{context}"]
= Invoking scripts embedded in an image

[role="_abstract"]
To extend builder image behavior while preserving supported script logic and upgrade compatibility in {product-title}, you can start embedded S2I image scripts by creating wrapper scripts.
These wrapper scripts run custom logic and then call the default scripts from the image.

.Procedure

. Inspect the value of the `io.openshift.s2i.scripts-url` label to determine the location of the scripts inside of the builder image:
+
[source,terminal]
----
$ podman inspect --format='{{ index .Config.Labels "io.openshift.s2i.scripts-url" }}' wildfly/wildfly-centos7
----
+
.Example output
[source,terminal]
----
image:///usr/libexec/s2i
----

. Create a script that includes an invocation of one of the standard scripts wrapped in other commands:
+
.`.s2i/bin/assemble` script
[source,bash]
----
#!/bin/bash
echo "Before assembling"

/usr/libexec/s2i/assemble
rc=$?

if [ $rc -eq 0 ]; then
    echo "After successful assembling"
else
    echo "After failed assembling"
fi

exit $rc
----
+
This example shows a custom assemble script that prints the message, runs the standard assemble script from the image, and prints another message depending on the exit code of the assemble script.
+
[IMPORTANT]
====
When wrapping the run script, you must use `exec` for invoking it to ensure signals are handled properly. The use of `exec` also precludes the ability to run additional commands after invoking the default image run script.
====
+
.`.s2i/bin/run` script
[source,bash]
----
#!/bin/bash
echo "Before running application"
exec /usr/libexec/s2i/run
----
