diskimage-builder/elements/rhel-common/finalise.d/60-unregister
Bernard Cafarelli 87379da56a Run RHEL system unregister element earlier
This does not need to be the last finalise step, and some late finalise
steps can disable the network (for example, Octavia amphora DIB cleans
resolv.conf at 99) Moving it to 60 also aligns it with rhsm-unregister
rhel6 element, and still allows to run subscription-manager steps
before.

Also fix an unbound variable error that appeared when both
BASE_IMAGE_FILE and DIB_CLOUD_IMAGES are unset.

Change-Id: Icb0e20b01479fea345e01309fc4bf3f7f639900c
2016-06-22 17:10:04 +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