LoginSignup
8
8

More than 5 years have passed since last update.

Intel Edisonに起動スクリプトを登録する

Posted at

 皆さんubilinuxにしてますよね?そうであれば,Debianの場合と同じです.

  /etc/init.d/ の中に,以下のようなshスクリプトを作成します.

myboot
#! /bin/sh
### BEGIN INIT INFO
# Provides:          myboot
# Required-Start:    
# Required-Stop:      
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: My initscript
# Description:       My initscript
### END INIT INFO

case "$1" in
  start)
    #nop
    ;;
  stop)
    #nop
    ;;
  status)
    #nop
    ;;
  restart|reload|force-reload)
    #nop
    ;;
esac

:

最後のコロンを忘れないように注意.

 作成したら,
# insserv myboot
で登録すると,

$ sudo find /etc/ -name "*myboot"
/etc/rc3.d/S01myboot
/etc/init.d/myboot
/etc/rc2.d/S01myboot
/etc/rc6.d/K01myboot
/etc/rc1.d/K01myboot
/etc/rc0.d/K01myboot
/etc/rc5.d/S01myboot
/etc/rc4.d/S01myboot

と,それぞれのランレベルに一度にスクリプトが登録されました!これらは全てシンボリックリンクなので,/etc/init.d/以下のスクリプトをいじれば,全てのランレベルの起動時に反映されます.

 解除は
# insserv -r myboot
になります.

 スクリプトの説明をすると,このスクリプトは,システムの起動時や終了時などに呼ばれます.その,自分自身がどのタイミングで呼ばれたのかを,

case "$1" in

以下で条件分岐しています.
 ここで,起動時に実行したい処理は,start以下に.終了時に実行したい処理はstop以下に記述してください.

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8