Solaris ソフトウェアのシステムへのインストールが完了すると、システムは再起動します。ブートプロセス終了前に、システムは root パスワードを入力するように求めてきます。パスワードを入力するまで、システムはブート処理を終了できません。
set_root_pw という終了スクリプトが、auto_install_sample ディレクトリに保存されています。この終了スクリプトは、プロンプトを表示することなく root パスワードを自動的に設定する方法を示します。set_root_pw については、例 4–6 を参照してください。
システムの root パスワードを終了スクリプトで設定した場合、ユーザーが、終了スクリプト内にある暗号化されたパスワードからルートのパスワードを発見しようと試みる可能性があります。ユーザーに root パスワードを解読されないよう、対策を講じてください。
| 	 #!/bin/sh
	 #
	 #       @(#)set_root_pw 1.4 93/12/23 SMI
	 #
	 # This is an example Bourne shell script to be run after installation.
	 # It sets the system's root password to the entry defined in PASSWD.
	 # The encrypted password is obtained from an existing root password entry
	 # in /etc/shadow from an installed machine.
 
	 echo "setting password for root"
 
	 # set the root password
 PASSWD=dKO5IBkSF42lw
	 #create a temporary input file
 cp /a/etc/shadow /a/etc/shadow.orig
 
	 mv /a/etc/shadow /a/etc/shadow.orig
 	nawk -F: '{
         if ( $1 == "root" )
           printf"%s:%s:%s:%s:%s:%s:%s:%s:%s\n",$1,passwd,$3,$4,$5,$6,$7,$8,$9
      else
		        printf"%s:%s:%s:%s:%s:%s:%s:%s:%s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9
      }' passwd="$PASSWD" /a/etc/shadow.orig > /a/etc/shadow
 #remove the temporary file
 rm -f /a/etc/shadow.orig
 # set the flag so sysidroot won't prompt for the root password
 sed -e 's/0 # root/1 # root/' ${SI_SYS_STATE} > /tmp/state.$$
  mv /tmp/state.$$ ${SI_SYS_STATE} | 
次に、この例のいくつかのコマンドの説明を示します。
次のコマンドは、PASSWD 変数に、システムの /etc/shadow ファイルの既存のエントリから取得した暗号化された root パスワードを設定します。
| #create a temporary input file | 
次のコマンドは、/a/etc/shadow の一時入力ファイルを作成します。
| cp /a/etc/shadow /a/etc/shadow.orig | 
次のコマンドは、$PASSWD をパスワードフィールドとして使用して、新しくインストールしたシステム用の /etc/shadow ファイルにある root エントリを変更します。
| if ( $1 == "root" ) | 
次のコマンドは、一時的な /a/etc/shadow ファイルを削除します。
| rm -f /a/etc/shadow.orig | 
次のコマンドは、状態ファイルのエントリを 0 から 1 へ変更します。これによりユーザーは root パスワードの入力を求められません。この状態ファイルには、SI_SYS_STATE 変数 (現在の値は /a/etc/.sysIDtool.state) を使用してアクセスします。この値の変更によってスクリプトで問題が発生することを防ぐには、必ず $SI_SYS_STATE を使用してこのファイルを参照してください。ここに示されている sed コマンドでは、0 の後ろと 1 の後ろにタブ文字が入っています。
| sed -e 's/0 # root/1 # root/' ${SI_SYS_STATE} > /tmp/state.$$ |