3 # dib-lint: disable=setu sete setpipefail dibdebugtrace
8 OK=/mnt/state/var/lib/rhsm/rhsm.ok
16 repos="repos --enable rhel-7-server-rpms"
17 satellite_repo="rhel-7-server-rh-common-rpms"
18 if [ -n "${REG_AUTO_ATTACH:-}" ]; then
19 opts="$opts --auto-attach"
21 if [ -n "${REG_SERVICE_LEVEL:-}" ]; then
22 opts="$opts --servicelevel $REG_SERVICE_LEVEL"
25 if [ -n "${REG_RELEASE:-}" ]; then
26 opts="$opts --release=$REG_RELEASE"
29 if [ -n "${REG_SERVICE_LEVEL:-}" ]; then
30 echo "WARNING: REG_SERVICE_LEVEL set without REG_AUTO_ATTACH."
33 if [ -n "${REG_RELEASE:-}" ]; then
34 echo "WARNING: REG_RELEASE set without REG_AUTO_ATTACH."
37 if [ -n "${REG_POOL_ID:-}" ]; then
38 attach_opts="$attach_opts --pool=$REG_POOL_ID"
42 if [ -n "${REG_BASE_URL:-}" ]; then
43 opts="$opts --baseurl=$REG_BASE_URL"
46 if [ -n "${REG_ENVIRONMENT:-}" ]; then
47 opts="$opts --env=$REG_ENVIRONMENT"
50 if [ -n "${REG_FORCE:-}" ]; then
54 if [ -n "${REG_SERVER_URL:-}" ]; then
55 opts="$opts --serverurl=$REG_SERVER_URL"
58 if [ -n "${REG_ACTIVATION_KEY:-}" ]; then
59 opts="$opts --activationkey=$REG_ACTIVATION_KEY"
61 if [ -z "${REG_ORG:-}" ]; then
62 echo "WARNING: REG_ACTIVATION_KEY set without REG_ORG."
65 echo "WARNING: Support for registering with a username and password is deprecated."
66 echo "Please use activation keys instead. See the README for more information."
67 if [ -n "${REG_PASSWORD:-}" ]; then
68 opts="$opts --password $REG_PASSWORD"
71 if [ -n "${REG_USER:-}" ]; then
72 opts="$opts --username $REG_USER"
76 if [ -n "${REG_MACHINE_NAME:-}" ]; then
77 opts="$opts --name $REG_MACHINE_NAME"
80 if [ -n "${REG_ORG:-}" ]; then
81 opts="$opts --org=$REG_ORG"
84 if [ -n "${REG_REPOS:-}" ]; then
85 for repo in $(echo $REG_REPOS | tr ',' '\n'); do
86 repos="$repos --enable $repo"
90 if [ -n "${REG_TYPE:-}" ]; then
91 opts="$opts --type=$REG_TYPE"
94 case "${REG_METHOD:-}" in
96 subscription-manager register $opts
97 if [ -z "${REG_AUTO_ATTACH:-}" -a -z "${REG_ACTIVATION_KEY:-}" ]; then
98 subscription-manager attach $attach_opts
100 subscription-manager $repos
103 repos="$repos --enable ${satellite_repo}"
104 rpm -Uvh "$REG_SAT_URL/pub/katello-ca-consumer-latest.noarch.rpm" || true
105 subscription-manager register $opts
106 subscription-manager $repos
107 yum install -y katello-agent || true # needed for errata reporting to satellite6
108 katello-package-upload
109 subscription-manager repos --disable ${satellite_repo}
112 echo "Disabling RHEL registration"
115 echo "WARNING: only 'portal', 'satellite', and 'disable' are valid values for REG_METHOD."
119 mkdir -p $(dirname $OK)