Red Hat Training

A Red Hat training course is available for Red Hat Satellite

第4章 システム管理

Red Hat Satellite では、システムレベルのサポートと Red Hat システムおよびシステムのネットワークの管理機能を提供しています。本章では、各種システムと、効果的な管理を行うために組織内の機能グループにこれらのシステムをどのように編成できるかについて説明します。

4.1. Satellite へのシステムの登録

システムは、Red Hat Satellite からパッケージ更新を要求するクライアントマシンです。これらのシステムは、Satellite からの更新を登録し、受信できるように設定された物理マシンまたは仮想化システムです。システムを Satellite に登録するのは、重要なステップです。クライアントシステムは、デフォルトでは組織の Satellite ではなく、Red Hat Network に登録されるためです。登録方法について詳しくは、『Red Hat Satellite クライアント設定ガイド』 のクライアントの Satellite サーバーへの登録に関連する章を参照してください。

4.1.1. Red Hat Network Bootstrap を使用したシステムの登録

Red Hat Network は、手作業によるシステムの再設定の多くを自動化できる Red Hat Network Bootstrap というツールを提供しています。Red Hat Network BootstrapRed Hat Satellite Server インストールプログラム で欠かせない重要な役割を担い、インストール時のブートストラップスクリプトの生成を可能にします。
Red Hat Satellite Proxy Server の管理者と更新された Satellite 設定をお使いの管理者には、単独で使用できるブートストラップツールが必要になります。これはコマンド /usr/bin/rhn-bootstrap で呼び出される Red Hat Network Bootstrap により行われるため、Red Hat Satellite Server と Red Hat Satellite Proxy Server の両方にデフォルトでインストールされています。
正しく使用すれば、このツールが生成するスクリプトはどのクライアントシステムからも実行でき次のようなタスクを処理します。
  • クライアントのアプリケーションを Red Hat Satellite Proxy または Satellite に転送します
  • カスタムの GPG キーをインポートします
  • SSL 証明書をインストールします
  • アクティベーションキーを使ってシステムを Red Hat Network および特定のシステムグループとチャンネルに登録します
  • パッケージの更新、再起動、Red Hat Network 設定の変更など、設定後のさまざまな作業を実行します

警告

ただし、設定作業にスクリプトを使用することに伴うリスクもあります。SSL 証明書などのセキュリティツールはスクリプト自体によってインストールされます。このため、証明書はシステム上にはまだ存在せず、トランザクションの処理に使用することはできません。これにより、Satellite になりすまして偽のデータを送信される可能性が生じます。実際にはすべての Satellite とクライアントのシステムは顧客のファイアウォールの背後で動作することになり、外部からのトラフィックは制限されることになるため、こうした可能性は軽減されることになります。登録は SSL 経由で行われるために保護されています。
ブートストラップスクリプトの bootstrap.sh は、Red Hat Network サーバーの /var/www/html/pub/bootstrap/ ディレクトリに自動的に配置されます。スクリプトはここからダウンロードされ、すべてのクライアントシステムで実行されます。次のセクションで説明しているように、準備や生成後の編集がいくつか必要になります。ツールの全オプションの一覧は 「Red Hat Network Bootstrap オプションの設定」 を参照してください。サンプルスクリプトについては 「サンプルのブートストラップスクリプト」 を参照してください。

4.1.1.1. Red Hat Network Bootstrap インストールの準備

Red Hat Network Bootstrap (rhn-bootstrap) はクライアントシステムを正しく設定するために Red Hat Network のインフラストラクチャーを構成している他のコンポーネントに依存します。スクリプトを生成する前にまずこれらのコンポーネントの準備を行う必要があります。最初に行っておくべき準備を以下に示します。
  • スクリプトで呼び出されるアクティベーションキーを生成します。アクティベーションキーは Red Hat Enterprise Linux システムの登録、Red Hat Network サービスレベルのエンタイトルメント付与、特定のチャンネルやシステムグループへのサブスクライブなどをすべて一度の動作で完了します。アクティベーションキーを使用するには利用可能な Management エンタイトルメントがあること、複数のアクティベーションキーを1度に組み込むには Provisioning エンタイトルメントが必要になる点に注意してください。Red Hat Satellilte Web サイトの (Proxy 用の Red Hat Network 中央サーバーか Satellite の完全修飾ドメイン名のいずれかの) システム のカテゴリ内にある アクティベーションキー ページからアクティベーションキーを生成します。
  • Red Hat では RPM をカスタムの GNU Privacy Guard (GPG) キーで署名しておくことを推奨しています。スクリプトから照合できるようにキーを使用可能にします。『Red Hat Satellite リファレンスガイド』 の記載通りにキーを生成したら、そのキーを Red Hat Satellite Serverの /var/www/html/pub/ ディレクトリに配置します。『Red Hat Satellite リファレンスガイド』 の 『カスタム GPG キーをインポートする』 セクションを参照してください。
  • 認証局の SSL パブリック証明書の配備にスクリプトを使用する場合は、その証明書またはその証明書を含むパッケージ (RPM) を該当する Red Hat Network サーバーで使用できるようにしてから、--ssl-cert オプションを使ってスクリプト生成時にこれを組み込みます。詳細は、『クライアント設定ガイド』の SSL インフラストラクチャーのセクションを参照してください。
  • 再設定するシステムの種類に応じたブートストラップスクリプトを作成するために必要となる各種の値を手元に準備しておきます。Red Hat Network Bootstrap では再設定オプションの全セットが提供されるため、これを使用して、各種システムのタイプに適したブートストラップスクリプトをそれぞれ生成することができます。例えば、Web サーバーの再設定には bootstrap-web-servers.sh、アプリケーションサーバーの場合は bootstrap-app-servers.sh を使用することができます。オプションの全一覧は 「Red Hat Network Bootstrap オプションの設定」 を参照してください。

4.1.1.2. Bootstrap スクリプトの生成

これで必要なコンポーネントがすべて整いましたので、Red Hat Network Bootstrap を使用して必要なスクリプトを生成します。Red Hat Satellite Server または Red Hat Satellite Proxy Server に root としてログインし、rhn-bootstrap コマンドに必要なオプションと値を付けて発行します。オプションを付けないで発行すると、bootstrap.sh ファイルは bootstrap/ サブディレクトリ内に作成されます。このサブディレクトリにはホスト名、SSL 証明書、SSL と GPG の設定などのサーバーから派生した基本的な値や client-config-overrides.txt ファイルの呼び出しなどが含まれます。
少なくとも、次のような方法でアクティベーションキー、GPG キー、高度な設定オプションをスクリプトに組み込むことを強く推奨します。
  • --activation-keys オプションを使ってキーを組み込みます。「Red Hat Network Bootstrap インストールの準備」 に記載されているエンタイトルメント要件を考慮に入れてください。
  • スクリプトの生成時に、--gpg-key オプションを使ってキーのパスとファイル名を指定します。または、--no-gpg オプションを使うとクライアントシステム側でこの確認作業が行われなくなります。Red Hat ではセキュリティ対策として --gpg-key オプションの使用を推奨します。
  • --allow-config-actions フラグを組み込むと、スクリプトで設定する全クライアントシステム上でリモートによる設定管理が可能になります。複数のシステムを同時に再設定する場合に便利です。
  • --allow-remote-commands フラグを組み込むと、すべてのクライアントシステムでリモートによるスクリプトの使用が可能になります。設定管理と同様、複数システムの再設定に便利な機能です。
上記をすべて組み込むと次のようになります。
# rhn-bootstrap --activation-keys KEY1,KEY2 \
    --gpg-key /var/www/html/pub/MY_CORPORATE_PUBLIC_KEY \
    --allow-config-actions \
    --allow-remote-commands
実際のキーの名前を組み込むのを忘れないようにしてください。全オプションの一覧は 「Red Hat Network Bootstrap オプションの設定」 を参照してください。

4.1.1.3. Red Hat Network Bootstrap スクリプトの使い方

スクリプトの使用準備が完了したら、いつでもスクリプトを実行することができます。Red Hat Satellite Server または Red Hat Satellite Proxy Server にログインして、/var/www/html/pub/bootstrap/ ディレクトリに行き、次のコマンドを実行します。スクリプト名とホスト名はシステムタイプにあわせて適宜変更してください。
# cat bootstrap-EDITED-NAME.sh | ssh root@CLIENT_MACHINE1 /bin/bash
安全性は低くなりますが、wget または curl のいずれかを使用して各クライアントシステムからスクリプトを取り込み、実行していく方法もあります。各クライアントマシンにログインして次のコマンドを発行します。スクリプトとホスト名は適宜変更してください。
# wget -qO - \
    https://your-satellite.example.com/pub/bootstrap/bootstrap-EDITED-NAME.sh \
    | /bin/bash
または、curl を使用した場合は次のようになります。
# curl -Sks \
    https://your-satellite.example.com/pub/bootstrap/bootstrap-EDITED-NAME.sh \
    | /bin/bash
このスクリプトを各クライアントシステム上で実行した場合は、すべてが Red Hat Network サーバーを使用するように設定を行なう必要があります。

4.1.1.4. Red Hat Network Bootstrap オプションの設定

Red Hat Bootstrap では、クライアントのブートストラップスクリプト作成に多くのコマンドラインオプションを提供しています。オプションの説明は次の表にありますが、これらのオプションが Red Hat Network Server にインストールしているツールのバージョンで使用できるか確認する必要があります。この確認を行うには、rhn-bootstrap --help を発行するか、または man ページを参照してください。

表4.1 Red Hat Network Bootstrap のオプション

オプション 説明
-h--help ブートストラップスクリプトの生成を行なう場合に使用するオプション一覧と共にヘルプ画面を表示します。
--activation-keys=ACTIVATION_KEYS アクティベーションキーです。複数のエントリの場合はコンマで区切り空白は入れません。
--overrides=OVERRIDES 無視するファイル名です。デフォルトは client-config-overrides.txt です。
--script=SCRIPT ブートストラップスクリプトのファイル名です。デフォルトは bootstrap.sh です。
--hostname=HOSTNAME クライアントシステムの接続先となるサーバーの完全修飾ドメイン名 (FQDN) です。
--ssl-cert=SSL_CERT 組織のパブリック SSL 証明書へのパスで、パッケージまたは生の証明書になります。--pub-tree オプションにコピーされます。 "" の値で --pub-tree の検索を強制します。
--gpg-key=GPG_KEY 企業または組織のパブリック GPG キーへのパスです (使用する場合)。 --pub-tree オプションによって指定した場所にコピーされます。
--http-proxy=HTTP_PROXY hostname:port の形式のクライアントシステム用 HTTP プロキシの設定です。"" の値でこの設定が無効になります。
--http-proxy-username=HTTP_PROXY_USERNAME HTTP プロキシの認証に使用する場合はユーザー名を指定します。"" の値を使うとこの設定は無効になります。
--http-proxy-password=HTTP_PROXY_PASSWORD HTTP プロキシの認証に使用する場合はパスワードを指定します。
--allow-config-actions Boolean です。このオプションを組み込むと、システムは Red Hat Network 経由の設定動作をすべて許可するようになります。このオプションを設定する場合は、アクティベーションキーなどを使って、特定の rhncfg-* パッケージをインストールする必要があります。
--allow-remote-commands Boolean です。このオプションを組み込むと、システムは Red Hat Network 経由の任意のリモートコマンドを許可するようになります。おそらくアクティベーションキーを使って特定の rhncfg-* パッケージのインストールが必要になります。
--no-ssl 推奨できません。 Boolean です。このオプションを組み込むと、クライアントシステムの SSL がオフになります。
--no-gpg 推奨できません。 Boolean です。このオプションを組み込むと、クライアントシステム上で GPG のチェックがオフになります。
--pub-tree=PUB_TREE 変更は推奨できません。 CA SSL 証書とパッケージが格納されるパブリックディレクトリのツリーです (ブートストラップのディレクトリとスクリプト群)。 デフォルトは /var/www/html/pub/ です。
--force 推奨できません。 Boolean です。このオプションを組み込むと、警告を無視してブートストラップスクリプトの生成を強制します。
-v--verbose 詳細なメッセージを表示します。表示レベルが累積的に詳細となり、 -vvv で最大の詳細レベル表示になります。

4.1.1.5. Red Hat Network Bootstrap 設定の手作業によるスクリプト化

本セクションでは、ブートストラップスクリプトを生成する際に Red Hat Network Bootstrap を使用しない方法について説明しています。記載されている説明に従うと、ゼロから独自のブートストラップスクリプトを作成することができるはずです。
集中管理を行なう場所に必要なファイル群を配備し、各クライアントで実行できるシンプルでスクリプト化が可能なコマンドを使ってそのファイルを取得し、インストールを行なう、というのが共通の目的です。本セクションでは、この目的に沿った単一のスクリプトで、企業や組織内のいずれのシステムからでも呼び出すことができるスクリプトの作成について見ていくことにします。
前のセクションで説明したコマンドをすべてまとめて適切な順序で並べると、以下のようなスクリプトを作成することができます。

# Reconfigure the clients to talk to the correct server.

perl -p -i -e 's/s/www\.rhns\.redhat\.com/proxy-or-sat\.example\.com/g' \
	/etc/sysconfig/rhn/rhn_register \
	/etc/sysconfig/rhn/up2date


# Install the SSL client certificate for your company's
# Red Hat Satellite Server or Red Hat Network Proxy Server.
rpm -Uvh http://proxy-or-sat.example.com/pub/rhn-org-trusted-ssl-cert-*.noarch.rpm

# Reconfigure the clients to use the new SSL certificate.
perl -p -i -e 's/^sslCA/#sslCA/g;' \
	/etc/sysconfig/rhn/up2date /etc/sysconfig/rhn/rhn_register
echo "sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT" \
	>> /etc/sysconfig/rhn/up2date
echo "sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT" \
	>> /etc/sysconfig/rhn/rhn_register


# Download the GPG key needed to validate custom packages.
wget -O - -q http://proxy-or-sat.example.com.com/pub/YOUR-RPM-GPG-KEY


# Import that GPG key to your GPG keyring.
rpm --import /path/to/YOUR-RPM-GPG-KEY
このスクリプトは完全で反復可能なプロセスで構成されています。Red Hat Satellite クライアントを設定して、Red Hat Satellite Proxy Server や Red Hat Satellite への登録の準備までを完了させることができるはずです。Red Hat Satellite サーバーの URL、そのパブリックディレクトリ、および実際の GPG キーなど、必要な値をスクリプト内にあるプレースホルダーに必ず入力してください。また、使用環境に応じて追加の修正が必要となる場合があります。本スクリプトはほとんどこのままでも機能しますが参考として使用するようにしてください。
コンポーネントと同様に、このスクリプトも集中管理を行なう場所に配置することができます。スクリプトをサーバーの /pub/ ディレクトリ内に配置し、そのサーバー上で wget -O- を実行し、その出力をシェルセッションに入力すると、各クライアントから単一のコマンドを使用してブートストラップの全プロセスを実行することができるようになります。
# wget -O - http://proxy-or-sat.example.com.com/pub/bootstrap_script | bash

警告

Web 接続で取得して入力されるスクリプトの内容をシェルスクリプトとして直接実行することにはそれなりの危険も伴います。したがってソースとなるサーバーの安全性を必ず確保することが非常に重要となります。
次に、この 1 行のコマンドを、ネットワーク上の全システムに対して起動することができます。また、既存のキックスタートスクリプトの %post セクションにこのスクリプトを追加することもできます。

4.1.1.6. キックスタートの実装

システムに設定変更を加えるタイミングとしては、そのシステムをはじめて構成する時が最も適しています。すでにキックスタートを効率的に使用している場合、ブートストラップを行うスクリプトをそのプロセスに追加するのが良いでしょう。
設定に関する問題がすべて解決したら、rhn-setup RPM に同梱されている rhnreg_ks ユーティリティを使用して、ローカルの Red Hat Network Server にシステムを登録することができます。本セクションではシステムを登録するために rhnreg_ks を正しく使用する方法について説明しています。
rhnreg_ks ユーティリティは、アクティベーションキー を使用して 1 回の操作でシステムの登録からエンタイトルメントの付与、指定チャンネルへのサブスクライブまで一度に行います。アクティベーションキーについての詳細は 『Red Hat Network Management Reference Guide』 の「RHN Website」と「Red Hat Update Agent」のセクションを参照してください。
以下のコメント付きキックスタートファイルは、Red Hat Satellite を使用してどのようにシステムが設定されていくのかを見る上で理想的な設定例となります。
# Generic 7.2 kickstart for laptops in the Widget Corporation (widgetco)

# Standard kickstart options for a network-based install. For an
# explanation of these options, consult the Red Hat Enterprize Linux
# Customization Guide.

lang en_US
langsupport --default en_US en_US
keyboard defkeymap
network --bootproto dhcp
install
url --url ftp://ftp.widgetco.com/pub/redhat/linux/7.2/en/os/i386
zerombr yes
clearpart --all
part /boot   --size 128 --fstype ext3 --ondisk hda
part /       --size 2048 --grow --fstype ext3 --ondisk hda
part /backup --size 1024 --fstype ext3 --ondisk hda
part swap    --size 512 --ondisk hda
bootloader --location mbr
timezone America/New_York
rootpw --iscrypted $1$78Jnap82Hnd0PsjnC8j3sd2Lna/Hx4.
auth --useshadow --enablemd5 --krb5realm .COM --krb5kdc auth.widgetco.com \
  --krb5adminserver auth.widgetco.com
mouse --emulthree genericps/2
xconfig --card "S3 Savage/MX" --videoram 8192  --resolution 1024x768 \
  --depth 16 --defaultdesktop=GNOME --startxonboot --noprobe \
  --hsync 31.5-48.5 --vsync 40-70

reboot

# Define a standard set of packages. Note: Red Hat Network client
# packages are found in the Base channel. This is quite a minimal
# set of packages

%packages
@ Base
@ Utilities
@ GNOME
@ Laptop Support
@ Dialup Support
@ Software Development
@ Graphics and Image Manipulation
@ Games and Entertainment
@ Sound and Multimedia Support


%post
( # Note that we run the entire %post section as a subshell for logging.

# Use the one-line command for the bootstrap script. Assuming that the
# script has been properly configured, it should prepare the system
# fully for usage of local Red Hat Network Servers.

wget -O- http://proxy-or-sat.example.com/pub/bootstrap_script | /bin/bash

# The following is an example of rhnreg_ks usage, the kickstart
# utility for rhn_register. This demonstrates the usage of the
# --activationkey flag, which describes an activation key. For example,
# this activation key could be set up in the Web interface to join this
# system to the "Laptops" group and the local "Laptop Software"
# channel. Note that this section applies only to Proxy server users, as
# this step is handled by the Satellite bootstrap script.
#
# For more information about activation keys, consult the Red Hat Network
# Management Reference Guide.

/usr/sbin/rhnreg_ks --activationkey=6c933ea74b9b002f3ac7eb99619d3374

# End the subshell and capture any output to a post-install log file.
) 1>/root/post_install.log 2>&1

4.1.1.7. サンプルのブートストラップスクリプト

Red Hat Satellite Server インストールプログラムによって生成される /var/www/html/pub/bootstrap/bootstrap.sh スクリプトでは、Red Hat Satellite Server にクライアントシステムをアクセスさせるための再設定を簡単に行なえる機能を提供しています。Red Hat Satellite Server および Red Hat Satellite Proxy Server をご利用のお客様は、RHN Bootstrap ツールでこの機能をご使用いただけます。使用状況に合わせてスクリプトを修正してから、各クライアントマシンでそのスクリプトを実行します。
詳細については、サンプルとハッシュマーク (#) で始まるコメントを確認してください。『スタートガイド』 の手順に従ってスクリプトの使用準備を行います。
#!/bin/bash
echo "Red Hat Satellite Server Client bootstrap script v4.0"

# This file was autogenerated. Minor manual editing of this script (and
# possibly the client-config-overrides.txt file) may be necessary to complete
# the bootstrap setup. Once customized, the bootstrap script can be triggered
# in one of two ways (the first is preferred):
#
#   (1) centrally, from the RHN Satellite Server via ssh (i.e., from the
#       RHN Satellite Server):
#         cd /var/www/html/pub/bootstrap/
#         cat bootstrap-<edited_name>.sh | ssh root@<client-hostname> /bin/bash
#
#   ...or...
#
#   (2) in a decentralized manner, executed on each client, via wget or curl:
#         wget -qO- https://<hostname>/pub/bootstrap/bootstrap-<edited_name>.sh | /bin/bash
#         ...or...
#         curl -Sks https://<hostname>/pub/bootstrap/bootstrap-<edited_name>.sh | /bin/bash

# SECURITY NOTE:
#   Use of these scripts via the two methods discussed is the most expedient
#   way to register machines to your RHN Satellite Server. Since "wget" is used
#   throughout the script to download various files, a "Man-in-the-middle"
#   attack is theoretically possible.
#
#   The actual registration process is performed securely via SSL, so the risk
#   is minimized in a sense. This message merely serves as a warning.
#   Administrators need to appropriately weigh their concern against the
#   relative security of their internal network.

# PROVISIONING/KICKSTART NOTE:
#   If provisioning a client, ensure the proper CA SSL public certificate is
#   configured properly in the post section of your kickstart profiles (the
#   RHN Satellite or hosted web user interface).

# UP2DATE/RHN_REGISTER VERSIONING NOTE:
#   This script will not work with very old versions of up2date and
#   rhn_register.


echo
echo
echo "MINOR MANUAL EDITING OF THIS FILE MAY BE REQUIRED!"
echo
echo "If this bootstrap script was created during the initial installation"
echo "of an RHN Satellite, the ACTIVATION_KEYS, and ORG_GPG_KEY values will"
echo "probably *not* be set (see below). If this is the case, please do the"
echo "following:"
echo "  - copy this file to a name specific to its use."
echo "    (e.g., to bootstrap-SOME_NAME.sh - like bootstrap-web-servers.sh.)"
echo "  - on the website create an activation key or keys for the system(s) to"
echo "    be registered."
echo "  - edit the values of the VARIABLES below (in this script) as"
echo "    appropriate:"
echo "    - ACTIVATION_KEYS needs to reflect the activation key(s) value(s)"
echo "      from the website. XKEY or XKEY,YKEY"
echo "    - ORG_GPG_KEY needs to be set to the name(s) of the corporate public"
echo "      GPG key filename(s) (residing in /var/www/html/pub) if appropriate. XKEY or XKEY,YKEY"
echo
echo "Verify that the script variable settings are correct:"
echo "    - CLIENT_OVERRIDES should be only set differently if a customized"
echo "      client-config-overrides-VER.txt file was created with a different"
echo "      name."
echo "    - ensure the value of HOSTNAME is correct."
echo "    - ensure the value of ORG_CA_CERT is correct."
echo
echo "Enable this script: comment (with #'s) this block (or, at least just"
echo "the exit below)"
echo
exit 1

# can be edited, but probably correct (unless created during initial install):
# NOTE: ACTIVATION_KEYS *must* be used to bootstrap a client machine.
ACTIVATION_KEYS=
ORG_GPG_KEY=

# can be edited, but probably correct:
CLIENT_OVERRIDES=client-config-overrides.txt
HOSTNAME=yoursatellite.hostname.com

ORG_CA_CERT=RHN-ORG-TRUSTED-SSL-CERT
ORG_CA_CERT_IS_RPM_YN=0

USING_SSL=1
USING_GPG=1

REGISTER_THIS_BOX=1

ALLOW_CONFIG_ACTIONS=1
ALLOW_REMOTE_COMMANDS=1

FULLY_UPDATE_THIS_BOX=1

# Set if you want to specify profilename for client systems.
# NOTE: Make sure it's set correctly if any external command is used.
#
# ex. PROFILENAME="foo.example.com"  # For specific client system
#     PROFILENAME=`hostname -s`      # Short hostname
#     PROFILENAME=`hostname -f`      # FQDN
PROFILENAME=""   # Empty by default to let it be set automatically.

#
# -----------------------------------------------------------------------------
# DO NOT EDIT BEYOND THIS POINT -----------------------------------------------
# -----------------------------------------------------------------------------
#

# an idea from Erich Morisse (of Red Hat).
# use either wget *or* curl
# Also check to see if the version on the
# machine supports the insecure mode and format
# command accordingly.

if [ -x /usr/bin/wget ] ; then
    output=`LANG=en_US /usr/bin/wget --no-check-certificate 2>&1`
    error=`echo $output | grep "unrecognized option"`
    if [ -z "$error" ] ; then
        FETCH="/usr/bin/wget -q -r -nd --no-check-certificate"
    else
        FETCH="/usr/bin/wget -q -r -nd"
    fi

else
    if [ -x /usr/bin/curl ] ; then
        output=`LANG=en_US /usr/bin/curl -k 2>>&1`
        error=`echo $output | grep "is unknown"`
        if [ -z "$error" ] ; then
            FETCH="/usr/bin/curl -SksO"
        else
            FETCH="/usr/bin/curl -SsO"
        fi
    fi
fi
HTTP_PUB_DIRECTORY=http://${HOSTNAME}/pub
HTTPS_PUB_DIRECTORY=https://${HOSTNAME}/pub
if [ $USING_SSL -eq 0 ] ; then
    HTTPS_PUB_DIRECTORY=${HTTP_PUB_DIRECTORY}
fi

INSTALLER=up2date
if [ -x /usr/bin/zypper ] ; then
    INSTALLER=zypper
elif [ -x /usr/bin/yum ] ; then
    INSTALLER=yum
fi
echo
echo "UPDATING RHN_REGISTER/UP2DATE CONFIGURATION FILES"
echo "-------------------------------------------------"
echo "* downloading necessary files"
echo "  client_config_update.py..."
rm -f client_config_update.py
$FETCH ${HTTPS_PUB_DIRECTORY}/bootstrap/client_config_update.py
echo "  ${CLIENT_OVERRIDES}..."
rm -f ${CLIENT_OVERRIDES}
$FETCH ${HTTPS_PUB_DIRECTORY}/bootstrap/${CLIENT_OVERRIDES}

if [ ! -f "client_config_update.py" ] ; then
    echo "ERROR: client_config_update.py was not downloaded"
    exit 1
fi
if [ ! -f "${CLIENT_OVERRIDES}" ] ; then
    echo "ERROR: ${CLIENT_OVERRIDES} was not downloaded"
    exit 1
fi

echo "* running the update scripts"
if [ -f "/etc/sysconfig/rhn/rhn_register" ] ; then
    echo "  . rhn_register config file"
    /usr/bin/python -u client_config_update.py /etc/sysconfig/rhn/rhn_register ${CLIENT_OVERRIDES}
fi
echo "  . up2date config file"
/usr/bin/python -u client_config_update.py /etc/sysconfig/rhn/up2date ${CLIENT_OVERRIDES}

if [ ! -z "$ORG_GPG_KEY" ] ; then
    echo
    echo "* importing organizational GPG key"
    for GPG_KEY in $(echo "$ORG_GPG_KEY" | tr "," " "); do
	rm -f ${GPG_KEY}
	$FETCH ${HTTPS_PUB_DIRECTORY}/${GPG_KEY}
	# get the major version of up2date
	# this will also work for RHEL 5 and systems where no up2date is installed
	res=$(LC_ALL=C rpm -q --queryformat '%{version}' up2date | sed -e 's/\..*//g')
	if [ "x$res" == "x2" ] ; then
	    gpg $(up2date --gpg-flags) --import $GPG_KEY
	else
	    rpm --import $GPG_KEY
	fi
    done
fi

echo
echo "* attempting to install corporate public CA cert"
if [ $ORG_CA_CERT_IS_RPM_YN -eq 1 ] ; then
    rpm -Uvh --force --replacefiles --replacepkgs ${HTTPS_PUB_DIRECTORY}/${ORG_CA_CERT}
else
    rm -f ${ORG_CA_CERT}
    $FETCH ${HTTPS_PUB_DIRECTORY}/${ORG_CA_CERT}
    mv ${ORG_CA_CERT} /usr/share/rhn/

fi
if [ "$INSTALLER" == zypper ] ; then
    if [  $ORG_CA_CERT_IS_RPM_YN -eq 1 ] ; then
      # get name from config
      ORG_CA_CERT=$(basename $(sed -n 's/^sslCACert *= *//p' /etc/sysconfig/rhn/up2date))
    fi
    test -e "/etc/ssl/certs/${ORG_CA_CERT}.pem" || {
      test -d "/etc/ssl/certs" || mkdir -p "/etc/ssl/certs"
      ln -s "/usr/share/rhn/${ORG_CA_CERT}" "/etc/ssl/certs/${ORG_CA_CERT}.pem"
    }
    test -x /usr/bin/c_rehash && /usr/bin/c_rehash /etc/ssl/certs/ | grep "${ORG_CA_CERT}"
fi

echo
echo "REGISTRATION"
echo "------------"
# Should have created an activation key or keys on the RHN Satellite Server's
# website and edited the value of ACTIVATION_KEYS above.
#
# If you require use of several different activation keys, copy this file and
# change the string as needed.
#
if [ -z "$ACTIVATION_KEYS" ] ; then
    echo "*** ERROR: in order to bootstrap RHN clients, an activation key or keys"
    echo "           must be created in the RHN web user interface, and the"
    echo "           corresponding key or keys string (XKEY,YKEY,...) must be mapped to"
    echo "           the ACTIVATION_KEYS variable of this script."
    exit 1
fi

if [ $REGISTER_THIS_BOX -eq 1 ] ; then
    echo "* registering"
    files=""
    directories=""
    if [ $ALLOW_CONFIG_ACTIONS -eq 1 ] ; then
        for i in "/etc/sysconfig/rhn/allowed-actions /etc/sysconfig/rhn/allowed-actions/configfiles"; do
            [ -d "$i" ] || (mkdir -p $i && directories="$directories $i")
        done
        [ -f /etc/sysconfig/rhn/allowed-actions/configfiles/all ] || files="$files /etc/sysconfig/rhn/allowed-actions/configfiles/all"
        [ -n "$files" ] && touch  $files
    fi
    if [ -z "$PROFILENAME" ] ; then
        profilename_opt=""
    else
        profilename_opt="--profilename=$PROFILENAME"
    fi
    /usr/sbin/rhnreg_ks --force --activationkey "$ACTIVATION_KEYS" $profilename_opt
    RET="$?"
    [ -n "$files" ] && rm -f $files
    [ -n "$directories" ] && rmdir $directories
    if [ $RET -eq 0 ]; then
      echo
      echo "*** this system should now be registered, please verify ***"
      echo
    else
      echo
      echo "*** Error: Registering the system failed."
      echo
      exit 1
    fi
else
  echo "* explicitly not registering"
fi

if [ $ALLOW_CONFIG_ACTIONS -eq 1 ] ; then
    echo
    echo "* setting permissions to allow configuration management"
    echo "  NOTE: use an activation key to subscribe to the tools"
    if [ "$INSTALLER" == zypper ] ; then
        echo "        channel and zypper install/update rhncfg-actions"
    elif [ "$INSTALLER" == yum ] ; then
        echo "        channel and yum upgrade rhncfg-actions"
    else
        echo "        channel and up2date rhncfg-actions"
    fi
    if [ -x "/usr/bin/rhn-actions-control" ] ; then
        rhn-actions-control --enable-all
        rhn-actions-control --disable-run
    else
        echo "Error setting permissions for configuration management."
        echo "    Please ensure that the activation key subscribes the"
	if [ "$INSTALLER" == zypper ] ; then
	    echo "    system to the tools channel and zypper install/update rhncfg-actions."
	elif [ "$INSTALLER" == yum ] ; then
            echo "    system to the tools channel and yum updates rhncfg-actions."
        else
            echo "    system to the tools channel and up2dates rhncfg-actions."
        fi
        exit
    fi
fi

if [ $ALLOW_REMOTE_COMMANDS -eq 1 ] ; then
    echo
    echo "* setting permissions to allow remote commands"
    echo "  NOTE: use an activation key to subscribe to the tools"
    if [ "$INSTALLER" == zypper ] ; then
        echo "        channel and zypper update rhncfg-actions"
    elif [ "$INSTALLER" == yum ] ; then
        echo "        channel and yum upgrade rhncfg-actions"
    else
        echo "        channel and up2date rhncfg-actions"
    fi
    if [ -x "/usr/bin/rhn-actions-control" ] ; then
        rhn-actions-control --enable-run
    else
        echo "Error setting permissions for remote commands."
        echo "    Please ensure that the activation key subscribes the"
        if [ "$INSTALLER" == zypper ] ; then
	    echo "    system to the tools channel and zypper updates rhncfg-actions."
	elif [ "$INSTALLER" == yum ] ; then
            echo "    system to the tools channel and yum updates rhncfg-actions."
        else
            echo "    system to the tools channel and up2dates rhncfg-actions."
        fi
        exit
    fi
fi

echo
echo "OTHER ACTIONS"
echo "------------------------------------------------------"
if [ $FULLY_UPDATE_THIS_BOX -eq 1 ] ; then
    if [ "$INSTALLER" == zypper ] ; then
        echo "zypper --non-interactive up zypper zypp-plugin-spacewalk; rhn-profile-sync; zypper --non-interactive up (conditional)"
    elif [ "$INSTALLER" == yum ] ; then
        echo "yum -y upgrade yum yum-rhn-plugin; rhn-profile-sync; yum upgrade (conditional)"
    else
        echo "up2date up2date; up2date -p; up2date -uf (conditional)"
    fi
else
    if [ "$INSTALLER" == zypper ] ; then
        echo "zypper --non-interactive up zypper zypp-plugin-spacewalk; rhn-profile-sync"
    elif [ "$INSTALLER" == yum ] ; then
        echo "yum -y upgrade yum yum-rhn-plugin; rhn-profile-sync"
    else
        echo "up2date up2date; up2date -p"
    fi
fi
echo "but any post configuration action can be added here.  "
echo "------------------------------------------------------"
if [ $FULLY_UPDATE_THIS_BOX -eq 1 ] ; then
    echo "* completely updating the box"
else
    echo "* ensuring $INSTALLER itself is updated"
fi
if [ "$INSTALLER" == zypper ] ; then
    zypper ref -s
    zypper --non-interactive up zypper zypp-plugin-spacewalk
    if [ -x /usr/sbin/rhn-profile-sync ] ; then
        /usr/sbin/rhn-profile-sync
    else
        echo "Error updating system info in RHN Satellite."
        echo "    Please ensure that rhn-profile-sync in installed and rerun it."
    fi
    if [ $FULLY_UPDATE_THIS_BOX -eq 1 ] ; then
        zypper --non-interactive up
    fi
elif [ "$INSTALLER" == yum ] ; then
    /usr/bin/yum -y upgrade yum yum-rhn-plugin
    if [ -x /usr/sbin/rhn-profile-sync ] ; then
        /usr/sbin/rhn-profile-sync
    else
        echo "Error updating system info in RHN Satellite."
        echo "    Please ensure that rhn-profile-sync in installed and rerun it."
    fi
    if [ $FULLY_UPDATE_THIS_BOX -eq 1 ] ; then
        /usr/bin/yum -y upgrade
    fi
else
    /usr/sbin/up2date up2date
    /usr/sbin/up2date -p
    if [ $FULLY_UPDATE_THIS_BOX -eq 1 ] ; then
        /usr/sbin/up2date -uf
    fi
fi
echo "-bootstrap complete-"