init(System-V)スクリプトをインストールするには、「insserv」にどのような手順が必要ですか?

init(System-V)スクリプトをインストールするには、「insserv」にどのような手順が必要ですか?

init学習目的でDebian WheezyはLSB initスクリプト(sysvinitパッケージバージョン2.88dsf-41 + deb7u1)を使用しました。私のスクリプトは次のとおりです。

# cat /etc/init.d/test-script
#! /bin/sh
### BEGIN INIT INFO
# Provides:          test
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: test script
# Description:       test script
### END INIT INFO

# always executes
touch /tmp/test-file

case "$1" in
  start)
    echo "Starting script test"
    touch /tmp/test-file-start
    ;;
  stop)
    echo "Stopping script test"
    touch /tmp/test-file-stop
    ;;
  restart)
    echo "Restarting script test"
    touch /tmp/test-file-restart
    ;;
  force-reload)
    echo "Force-reloading script test"
    touch /tmp/test-file-force-reload
    ;;
  status)
    echo "Status of test"
    touch /tmp/test-file-status
    ;;
  *)
    echo "Usage: /etc/init.d/test {start|stop}"
    exit 1
    ;;
esac

exit 0

#

/etc/init.d/test-scriptファイルを実行可能にし、/etc/rc2.d/ディレクトリにシンボリックリンクを追加しました。

lrwxrwxrwx 1 root root 21 Nov  2 13:19 /etc/rc2.d/S04test-script -> ../init.d/test-script

..デフォルトの実行レベルが2で、コンピュータを再読み込みしましたがスクリプトが起動しなかったためです。最後のステップとしてファイルtestに追加しましたが、起動中はまだ実行されません。/etc/init.d/.depend.start/etc/init.d/test-script

insservinitスクリプトをインストールするにはどのような追加手順が必要ですか?

ベストアンサー1

ディレクトリへのシンボリックリンクに加えて、/etc/rc<runlevel>.d/ファイルに1行を追加しますinsserv。私の間違いは、ファイルに行を追加したことです。次のLSBヘッダーを使用して、次のようにします。<script_name>:/etc/init.d/.depend.start<boot_facility>:/etc/init.d/.depend.start/etc/init.d/test-script

### BEGIN INIT INFO
# Provides:          test
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: test script
# Description:       test script
### END INIT INFO

..その後、1行の代わりにtest-script:1行を追加する必要があります。/etc/init.d/.depend.starttest:

おすすめ記事