diskimage-builder/elements/rhel-common/finalise.d/99-unregister
Pino Toscano 8d19032a4a Do not export REG_HALT_UNREGISTER between hook scripts
Do not rely on environment changes (like exporting REG_HALT_UNREGISTER)
to persist between different hooks run. This helps when the hooks are
run in different new environments every time.

Instead, in 99-unregister redo the same checks on REG_METHOD as done in
00-rhel-registration, still respecting REG_HALT_UNREGISTER in case the
user does not want to unregister the image generated.

Change-Id: Id594dcd72334f38a2fa96da21206da77a83d7a1a
Closes-Bug: #1434431
2015-04-08 09:28:47 +02:00

27 lines
910 B
Bash
Executable File

#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-1}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# When building an image with diskimage-builder, you will need to register
# with either the customer portal or a satellite instance in order to enable
# repos for software installation. In most cases, it is desirable to
# unregister a system when diskimage-builder is completing so the customer
# entitlements are not decremented. This option is here for the case when
# a single image needs to be built and deployed as a single instance or for
# debugging purposes so you can check the portal or satellite to see what was
# registered. Set REG_HALT_UNREGISTER to any non-null value to enable this
# functionality.
case "${REG_METHOD:-}" in
portal | satellite)
if [ -z "${REG_HALT_UNREGISTER:-}" ]; then
subscription-manager unregister
fi
;;
disable)
;;
esac