[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Policy-ja 3.3



これもお願いします。

================================================================

      <sect id="sysvinit">
	<!-- <heading>System run levels</heading> -->
	<heading>システムランレベル</heading>
	  
	<sect1 id="/etc/init.d">
	  <!-- <heading>Introduction</heading> -->
	  <heading>はじめに</heading>
	    
	  <p>
	    <!-- 
	    The <tt>/etc/init.d</tt> directory contains the scripts
	    executed by <prgn>init</prgn> at boot time and when init
	    state (or `runlevel') is changed (see <manref name="init"
	    section="8">). -->
	    <tt>/etc/init.d</tt>ディレクトリには <prgn>init</prgn>に
	    よって起動されるスクリプト群が収められています。これらはブー
	    ト時、そして init state (ランレベルともいう)を変える時に用
	    いられます。(<manref name="init"section="8">参照)
	  </p>

          <p>
	    <!-- There are at least two different, yet functionally
            equivalent, ways of handling these scripts.  For the sake
            of simplicity, this document describes only the symbolic
            link method. However, it may not be assumed that this
            method is being used, and any manipulation of the various
            runlevel behaviours must be performed using
            <prgn>update-rc.d</prgn> as described below and not by
            manually installing symlinks.  For information on the
            implementation details of the other method, implemented in
            the <tt>file-rc</tt> package, please refer to the
            documentation of that package. -->
	    これらのスクリプトを用いるにあたり、少なくとも二つ(機能上
	    は等しいものですが)方法があります。簡単のため、このドキュ
	    メントではシンボリックリンクによる方法のみを記します。しか
	    し、この方法だけが用いられていると思い込んではなりません。
	    それぞれのランレベルの挙動に対する操作は、手でシンボリック
	    リンクすることで導入せず、後述するように 
	    <prgn>update-rc.d</prgn> によって行われなくてはなりません。
	    <tt>file-rc</tt>パッケージに含まれている、この以外の方法に
	    よる実装の詳細については、パッケージのドキュメントを参照し
	    て下さい。
	  </p>

          <p>
            <!-- These scripts are referenced by symbolic links in
	    the <tt>/etc/rc<var>n</var>.d</tt> directories.  When
	    changing runlevels, <prgn>init</prgn> looks in the
	    directory <tt>/etc/rc<var>n</var>.d</tt> for the scripts
	    it should execute, where <var>n</var> is the runlevel that
	    is being changed to, or `S' for the boot-up scripts. -->
	    これらのスクリプトは<tt>/etc/rc<var>n</var>.d</tt>ディレクトリ
	    の中からシンボリックリンクが張られています。ランレベルを変
	    更すると、<prgn>init</prgn>は
	    <tt>/etc/rc<var>n</var>.d</tt>ディレクトリ内を見て、実行す
	    べきスクリプトを探します。ここで<var>n</var>は、これから変
	    更されるランレベルを示します。また `S' はブート時のスクリ
	    プトを指します。
	  </p>
	    
          <p>
	    <!-- The names of the links all have the form
	    <tt>S<var>mm</var><var>script</var></tt> or
	    <tt>K<var>mm</var><var>script</var></tt> where
	    <var>mm</var> is a two-digit number and <var>script</var>
	    is the name of the script (this should be the same as the
	    name of the actual script in <tt>/etc/init.d</tt>.  -->
	    リンクの名前は全て 
	    <tt>S<var>mm</var><var>script</var></tt> か
	    <tt>K<var>mm</var><var>script</var></tt> の形をとっていま
	    す。ここで<var>mm</var>は二桁の数字で、<var>script</var>は
	    スクリプトの名前を示しています(。この名前は
	    <tt>/etc/init.d</tt>内の実際のスクリプトと同一の名前にして
	    おくべきです。
	  </p>
	    
          <p>
	    <!-- When <prgn>init</prgn> changes runlevel first the
	    targets of the links whose names starting with a
	    <tt>K</tt> are executed, each with the single argument
	    <tt>stop</tt>, followed by the scripts prefixed with an
	    <tt>S</tt>, each with the single argument <tt>start</tt>.
	    The <tt>K</tt> links are responsible for killing services
	    and the <tt>S</tt> link for starting services upon
	    entering the runlevel. -->
	    <prgn>init</prgn> がランレベルを変更したとき、リンクの中で最
	    初にターゲットとなる<tt>K</tt>で始まるスクリプトが、それぞれ
	    に<tt>stop</tt>オプション付きで実行されます。次に
	    <tt>S</tt>で始まるスクリプトが<tt>start</tt>オプション付きで
	    起動されていきます。<tt>K</tt>で始まる名前でリンクを張られた
	    ものは、サービスを停止することに対応し、<tt>S</tt>の方は、そ
	    のランレベルになる時にサービスを開始することを示します。
	  </p>
	    
	  <p>
	    <!-- For example, if we are changing from runlevel 2 to
	    runlevel 3, init will first execute all of the <tt>K</tt>
	    prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
	    all of the <tt>S</tt> prefixed scripts.  The links
	    starting with <tt>K</tt> will cause the referred-to file
	    to be executed with an argument of <tt>stop</tt>, and the
	    <tt>S</tt> links with an argument of <tt>start</tt>. -->
	    例えば、ランレベル2から3へと移行したとします。
	    <prgn>init</prgn>は、<tt>/etc/rc3.d/</tt>にある全ての
	    <tt>K</tt>で始まるスクリプトを、その後<tt>S</tt>で始まるスク
	    リプトを実行していきます。<tt>K</tt>で始まるものはそれぞれに
	    対応したファイルを<tt>stop</tt>オプション付きで、そして
	    <tt>S</tt>で始まるリンク先を<tt>start</tt>オプション付きで実
	    行します。
	  </p>
	    
	  <p>
	    <!-- The two-digit number <var>mm</var> is used to decide
	    which order to start and stop things in-low-numbered links
	    have their scripts run first.  For example, the
	    <tt>K20</tt> scripts will be executed before the
	    <tt>K30</tt> scripts.  This is used when a certain service
	    must be started before another.  For example, the name
	    server <prgn>bind</prgn> might need to be started before
	    the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
	    can set up its access lists.  In this case, the script
	    that starts <prgn>bind</prgn> should have a lower number
	    than the script that starts <prgn>inn</prgn> so that it
	    runs first: --> 
	    <var>mm</var>で示した二桁の数字は、どういう順序で開始及び
	    停止を行うかを決定するのに用いられます。小さい数字から順番
	    に実行されます。例えば<tt>K20</tt>というふうに始まるスクリ
	    プトは<tt>K30</tt>で始まるものよりも先に実行されます。ある
	    サービスが他のサービスよりも先に開始していなければならない
	    ときに使うわけです。例えば、ネームサーバ<prgn>bind</prgn> 
	    はニュースサーバ<prgn>inn</prgn>がアクセスリストをセットアッ
	    プできるよう、それよりも先に起動しておく必要があるでしょう。
	    このケースでは<prgn>bind</prgn>を起動するスクリプトは
	    <prgn>inn</prgn>を起動するものよりも小さい番号にしておかね
	    ばなりません。
	    <example>
	      /etc/rc2.d/S17bind
	      /etc/rc2.d/S70inn
	    </example> 
	  </p>
	</sect1>
	  
	<sect1>
	  <!-- <heading>Writing the scripts</heading> -->
	  <heading>スクリプトの書き方</heading>
	    
	  <p>
	    <!-- Packages can and should place scripts in
	    <tt>/etc/init.d</tt> to start or stop services at boot
	    time or during a change of runlevel.  These scripts should
	    be named <tt>/etc/init.d/<var>package</var></tt>, and they
	    should accept one argument, saying what to do: -->
	    パッケージはブート時やランレベル変更時にサービスを開始及び
	    停止させるため、<tt>/etc/init.d</tt>にスクリプトをおくこと
	    ができ、またそれが推奨されています。
	    
	    <taglist>
	      <tag><tt>start</tt></tag>
	      <item>
		<p>
		  <!-- start the service, -->
		  サービスを開始します。
		</p></item>
		  
	      <tag><tt>stop</tt></tag>
	      <item>
		<p>
		  <!-- stop the service, -->
		  サービスを停止します。
		</p></item>
		  
	      <tag><tt>restart</tt></tag>
	      <item>
		<p>
		  <!-- stop and restart the service,-->
		  サービスを停止し、再起動します。
		</p></item>
		  
	      <tag><tt>reload</tt></tag>
	      <item>
		<p>
		  <!-- cause the configuration of the service to be
		  reloaded without actually stopping and restarting
		  the service, -->
		  サービスの設定をサービスを停止したり再起動することな
		  く再読み込みします。
		</p></item>
		  
	      <tag><tt>force-reload</tt></tag>
	      <item>
		<p>
		  <!-- cause the configuration to be reloaded if the
		  service supports this, otherwise restart the
		  service. -->
		  サービスが設定の再読み込みに対応しているならばそれを
		  行いますが、そうでなければ再起動します。
		</p></item>
	    </taglist>
	    
	    <!-- The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>,
	    and <tt>force-reload</tt> options must be supported by all
	    scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
	    option is optional. -->
	    <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>,
	    <tt>force-reload</tt> の各オプションは 
	    <tt>/etc/init.d</tt> 内の全てのスクリプトがサポートしてい
	    なければなりませんが、<tt>reload</tt>オプションのサポート
	    は任意です。
	  </p>
	    
	  <p>
	    <!-- The <tt>init.d</tt> scripts should ensure that they
	    will behave sensibly if invoked with <tt>start</tt> when
	    the service is already running, or with <tt>stop</tt> when
	    it isn't, and that they don't kill unfortunately-named
	    user processes.  The best way to achieve this is usually
	    to use <prgn>start-stop-daemon</prgn>. -->
	    <tt>init.d</tt> スクリプトは、該当するサービスが既に起動し
	    ているのに<tt>start</tt>オプション付きで実行された場合の動
	    作に慎重さが要求されます。逆に起動していないのに
	    <tt>stop</tt>オプション付きで実行されれば、他のユーザープ
	    ロセスを落させないようにしなくてはなりません。ベストの方法
	    は、常に<prgn>start-stop-daemon</prgn>を用いるようにするこ
	    とです。
	  </p>
	    
	  <p>
	    <!-- If a service reloads its configuration automatically
	    (as in the case of <prgn>cron</prgn>, for example), the
	    <tt>reload</tt> option of the <tt>init.d</tt> script
	    should behave as if the configuration has been reloaded
	    successfully. -->
	    もしサービスが設定を自動的に再読み込みするような場合(例え
	    ば <prgn>cron</prgn>などで)、<tt>init.d</tt>スクリプトに付
	    けられた<tt>reload</tt>オプションは、再読み込みに成功した
	    かのように振舞う必要があります。
	  </p>
	    
	  <p>
	    <!-- These scripts should not fail obscurely when the
	    configuration files remain but the package has been
	    removed, as configuration files remain on the system after
	    the package has been removed. Only when <prgn>dpkg</prgn>
	    is executed with the <tt>-purge</tt> option will
	    configuration files be removed. In particular, the init
	    script itself is usually a configuration file (see <ref
	    id="init.d notes">), and will remain on the system if the
	    package is removed but not purged. Therefore, you should
	    include a <tt>test</tt> statement at the top of the
	    script, like this: -->
	    パッケージ自体が削除されていても設定ファイルはシステムに残っ
	    ているため、その状態ではこれらスクリプトは曖昧な落ち方をし
	    ないようになっています。<prgn>dpkg</prgn>は
	    <tt>--purge</tt>オプション付きで実行されて初めて設定ファイ
	    ルを削除します。特に init スクリプト自体が設定ファイル
	    (<ref id="init.d notes">参照)である場合も多く、そのためパッ
	    ケージが削除されてもパージされていない状態ではシステムに残っ
	    たままになります。そこで、次のように<tt>test</tt>文をスク
	    リプトの先頭におくべきです。
	    
	    <example>
  test -f <var>program-executed-later-in-script</var> || exit 0
	    </example></p>
	</sect1>
	  
	<sect1>
	  <!-- <heading>Managing the links</heading> -->
	  <heading>リンクの取り扱い</heading>
	  <p>
	    <!-- A program is provided, <prgn>update-rc.d</prgn>, to
	    handle the it easier for package maintainers to arrange
	    for the proper creation and removal of
	    <tt>/etc/rc<var>n</var>.d</tt> symbolic links, or their
	    functional equivalent if another method is being used.
	    This may be used by maintainers in their packages'
	    <tt>postinst</tt> and <tt>postrm</tt> scripts. -->
	    <tt>/etc/rc<var>n</var>.d</tt>のシンボリックリンクの作成と
	    削除(他の方法であっても結果的に同じものである場合)の作業を
	    パッケージメンテナが簡単にできるようにするため、
	    <prgn>update-rc.d</prgn>というプログラムが配布されています。
	    このプログラムは、メンテナがパッケージ内の
	    <tt>postinst</tt>や<tt>postrm</tt>スクリプトの中で使います。
	  </p>
	    
	  <p>
	    <!-- You should use this script to make changes to
	    <tt>/etc/rc<var>n</var>.d</tt> and <em>never</em> either
	    include any <tt>/etc/rc<var>n</var>.d</tt> symbolic links
	    in the actual archive or manually create or remove the
	    symbolic links in maintainer scripts.  (The latter will
	    fail if an alternative method of maintaining runlevel
	    information is being used.) -->
	    <tt>/etc/rc<var>n</var>.d</tt> に変更を加えるときには必ず
	    このスクリプトを用い、<em>絶対に
	    </em><tt>/etc/rc<var>n</var>.d</tt>内のシンボリックリンク
	    を直接アーカイブに含めたり、メンテナ独自のスクリプトによっ
	    て作成及び削除を行ってはなりません。(後者の方法は、ランレ
	    ベル情報の取り扱いを新しい方法で行っていれば失敗します)
	  </p>
	    
	  <p>
	    <!-- By default <prgn>update-rc.d</prgn> will start
	    services in each of the multi-user state runlevels (2, 3,
	    4, and 5) and stop them in the halt runlevel (0), the
	    single-user runlevel (1) and the reboot runlevel (6).  The
	    system administrator will have the opportunity to
	    customize runlevels by either running
	    <prgn>update-rc.d</prgn>, by simply adding, moving, or
	    removing the symbolic links in
	    <tt>/etc/rc<var>n</var>.d</tt> if symbolic links are being
	    used, or by modifying <tt>/etc/runlevel.conf</tt> if the
	    <tt>file-rc</tt> method is being used. -->
	    デフォルトでは、<prgn>update-rc.d</prgn>はそれぞれのマルチ
	    ユーザー状態のランレベル(2,3,4,5)にて、各種サービスを開始
	    させ、halt(0)、シングルユーザー(1)、リブート(6)のそれぞれ
	    のランレベルでは停止するようにします。システムの管理者はシ
	    ンボリックリンクによる管理がなされている場合には
	    <prgn>update-rc.d</prgn>を実行して、
	    <tt>/etc/rc<var>n</var>.d</tt>のシンボリックリンクを追加、
	    移動、削除するだけで、また、<tt>file-rc</tt>による方法で管
	    理されていれば<tt>/etc/runlevel.conf</tt>を変更すれば、ラ
	    ンレベルをカスタマイズすることができます。
	  </p>
	    
	  <p>
	    <!-- To get the default behavior for your package, put in
	    your <tt>postinst</tt> script -->
	    自分のパッケージのデフォルトの挙動を取得するには、
	    <tt>postinst</tt>スクリプトに次のように書きます。
	    <example>
	      update-rc.d <var>package</var> defaults &gt;/dev/null
	    </example>
	    <!-- and in your <tt>postrm</tt> -->
	    <tt>postrm</tt> では次のようになります。
	    <example>
	      if [ purge = "$1" ]; then
	      update-rc.d <var>package</var> remove &gt;/dev/null
	      fi
	    </example>
	  </p>
	    
	  <p>
	    <!-- This will use a default sequence number of 20.  If it
	    does not matter when or in which order the script is run,
	    use this default.  If it does, then you should talk to the
	    maintainer of the <prgn>sysvinit</prgn> package or post to
	    <tt>debian-devel</tt>, and they will help you choose a
	    number. --> 
	    この方法ではデフォルトのシーケンス番号として20を使います。
	    それでスクリプトを動かした時、その順序で問題なければ、その
	    デフォルトを使うようにして下さい。そうでなければ
	    <prgn>sysvinit</prgn>パッケージのメンテナと連絡をとるか、
	    <tt>debian-devel</tt>にポストしましょう。番号の選択につい
	    て手助けしてもらえるはずです。
	  </p>
	    
	  <p>
	    <!-- For more information about using
	    <tt>update-rc.d</tt>, please consult its manpage <manref
	    name="update-rc.d" section="8">. -->
	    <tt>update-rc.d</tt>の使い方に関する情報は、man <manref
	    name="update-rc.d" section="8"> を見て下さい。
	  </p>
	</sect1>
	    
	    
	<sect1>
	  <!-- <heading>Boot-time initialization</heading> -->
	  <heading> ブート時における初期化 </heading>
	    
          <p>
	    <!-- There used to be another directory,
            <tt>/etc/rc.boot</tt>, which contained scripts which were
            run once per machine boot. This has been deprecated in
            favour of links from <tt>/etc/rcS.d</tt> to files in
            <tt>/etc/init.d</tt> as described in <ref
            id="/etc/init.d">.  No packages may place files in
            <tt>/etc/rc.boot</tt>. --> 
	    ホストをブートした時に一度だけ実行されるスクリプトをまとめ
            た<tt>/etc/rc.boot</tt>なるディレクトリが存在しましたが、
            <ref id="/etc/init.d">にある通り、<tt>/etc/rcS.d</tt>から
            <tt>/etc/init.d</tt>内のファイルへのリンクに置き換えること
            が推奨されています。パッケージが<tt>/etc/rc.boot</tt>にファ
            イルを置くことは許されていません。
	  </p>

	<sect1 id="init.d notes">
	  <!-- <heading>Notes</heading> -->
	  <heading>付記</heading>
	    
	  <p>
	    <!-- <em>Do not</em> include the
	    <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in the
	    <tt>.deb</tt> file system archive!  <em>This will cause
	    problems!</em> You should create them with
	    <prgn>update-rc.d</prgn>, as above. -->
	    <tt>/etc/rc<var>n</var>.d</tt> 内のシンボリックリンクを
	    <tt>.deb</tt>アーカイブに含めることは<em>問題を生ずるため、
	    してはなりません</em>。上記にあるように、その場合には
	    <prgn>update-rc.d</prgn>を使いましょう。
	  </p>
	
	  <p>
	    <!-- <em>Do not</em> include the
	    <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in
	    <prgn>dpkg</prgn>'s conffiles list!  <em>This will cause
	    problems!</em> <em>Do</em>, however, treat the
	    <tt>/etc/init.d</tt> scripts as configuration files,
	    either by marking them as conffiles or managing them
	    correctly in the maintainer scripts (see <ref id="config
	    files">). (This is important since we want to give the
	    local system administrator the chance to adapt the scripts
	    to the local system-e.g., to disable a service without
	    de-installing the package, or to specify some special
	    command line options when starting a service-while making
	    sure her changes aren't lost during the next package
	    upgrade.) -->
	    <tt>/etc/rc<var>n</var>.d</tt> 内のシンボリックリンクを
	    <prgn>dpkg</prgn>のconffilesリストに含めることは<em>問題を
	    生ずるため、してはなりません</em>。しかし、
	    <tt>/etc/init.d</tt>スクリプトは設定ファイルとして扱わなく
	    てはなりません。そのためには conffile としてマークし、メン
	    テナスクリプト(<ref id="config files">参照)の中で適切に扱
	    うことです。(ローカルシステムの管理者が、自分達のシステム
	    にあわせたスクリプトの変更ができるようにするために重要です
	    なことです。例えば、パッケージを削除すること無くサービスを
	    停止するとか、サービス開始時に特殊なコマンドラインオプショ
	    ンを指定したりする場合です。さらに、パッケージのアップグレー
	    ドに際してsの変更が失われないようにしなくてはなりません。)
	  </p>
	</sect1>
	    
	<sect1>
	  <!-- <heading>Example</heading> -->
	  <heading>実例</heading>
	    
	  <p>
	    <!-- The <prgn>bind</prgn> DNS (nameserver) package wants
	    to make sure that the nameserver is running in multiuser
	    runlevels, and is properly shut down with the system.  It
	    puts a script in <tt>/etc/init.d</tt>, naming the script
	    appropriately <tt>bind</tt>.  As you can see, the script
	    interprets the argument <tt>reload</tt> to send the
	    nameserver a <tt>HUP</tt> signal (causing it to reload its
	    configuration); this way the user can say
	    <tt>/etc/init.d/bind reload</tt> to reload the name
	    server. -->
	    <prgn>bind</prgn> という DNS(ネームサーバ)パッケージはマル
	    チユーザーのランレベルで稼働されていることを確実にすること、
	    さらにシステムに合わせてきちんとシャットダウンすることも要
	    求します。そのためにパッケージは<tt>bind</tt>というスクリ
	    プトを<tt>/etc/init.d</tt>に置きます。見れば分かりますが、
	    このスクリプトは<tt>reload</tt>オプションを、ネームサーバ
	    に <tt>HUP</tt>シグナルを送る(これで設定を再読み込みさせら
	    れます)ことと解釈します。この方法でユーザーは
	    <tt>/etc/init.d/bind reload</tt>とすればネームサーバの再読
	    み込みを行うことができます。
	  </p>
	    
	  <p>
	    <example>
	      #!/bin/sh
	      #
	      # Original version by Robert Leslie
	      # &lt;rob@xxxxxxxx&gt;, edited by iwj and cs
	      
	      test -x /usr/sbin/named || exit 0
	      
	      case "$1" in
	      start)
	      echo -n "Starting domain name service: named"
	      start-stop-daemon --start --quiet --exec /usr/sbin/named
	      echo "."
	      ;;
	      stop)
	      echo -n "Stopping domain name service: named"
	      start-stop-daemon --stop --quiet  \
	      --pidfile /var/run/named.pid --exec /usr/sbin/named
	      echo "."
	      ;;
	      restart)
	      echo -n "Restarting domain name service: named"
	      start-stop-daemon --stop --quiet  \
	      --pidfile /var/run/named.pid --exec /usr/sbin/named
	      start-stop-daemon --start --verbose --exec /usr/sbin/named
	      echo "."
	      ;;
	      force-reload|reload)
	      echo -n "Reloading configuration of domain name service: named"
	      start-stop-daemon --stop --signal 1 --quiet  \
	      --pidfile /var/run/named.pid --exec /usr/sbin/named
	      echo "."
	      ;;
	      *)
	      echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
	      exit 1
	      ;;
	      esac
	      
	      exit 0
	    </example>
	  </p>
	    
	  <p>
	    <!-- Another example on which to base your
	    <tt>/etc/init.d</tt> scripts is in
	    <tt>/etc/init.d/skeleton</tt>. -->
	    あなたの<tt>/etc/init.d</tt>スクリプトのベースとなる、別の
	    サンプルは<tt>/etc/init.d/skeleton</tt>にもあります。
	  </p>
	    
	  <p>
	    <!-- If this package is happy with the default setup from
	    <prgn>update-rc.d</prgn>, namely an ordering number of 20
	    and having named running in all runlevels, it can say in
	    its <tt>postinst</tt>: -->
	    もしこのパッケージが<prgn>update-rc.d</prgn>のデフォルト、
	    特に起動順序番号が20で、かつnamed を全てのランレベルで走ら
	    せる、という設定で満足するなら、<tt>postinst</tt>には次の
	    ように書けば良いことになります。
	    <example>
	      update-rc.d bind defaults >/dev/null
	    </example>
	    <!-- And in its <tt>postrm</tt>, to remove the links when
	    the package is purged: --> 
	    そして<tt>postrm</tt>には、パージの際にそのリンクを削除す
	    るために次のように書きます。
	    <example>
	      if [ purge = "$1" ]; then
	      update-rc.d acct remove >/dev/null
	      fi
	    </example>
	  </p>
	</sect1>
      </sect>