본문 바로가기
실전 임베디드

raspberry pi boot script /etc/init.d 실전 임베디드 2016. 2. 5. 16:29

by BABEL-II 2019. 9. 22.

/etc/init.d/remoled를 만들었으면

이걸 부팅 시에 실행하도록 등록해 줘야 한다

 

등록하는 명령

sudo update-rc.d /etc/init.d/remoletd defaults

또는

sudo update-rc.d remoletd defaults


 

NOTE: the following steps usually require root permissions. So just issue every command with sudo or log into a root shell (sudo -s, beware that everything you do is done with root permissions!!)
 

Code: Select all# update boot / reboot files
cp <your script> /etc/init.d/
# do it as soon as the device is going down,
#   both for shutdown and reboot
update-rc.d /etc/init.d/<your script> defaults


(If I couldn't have been clear enough, this has to be done after looking at the following part...)

The <your script> part is something like the following:
 

Code: Select all#! /bin/sh
### BEGIN INIT INFO
# Provides:          <your script name>
# Required-Start:    $all
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Manage my cool stuff
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions
# If you need to source some other scripts, do it here

case "$1" in
  start)
    log_begin_msg "Starting my super cool service"
# do something
    log_end_msg $?
    exit 0
    ;;
  stop)
    log_begin_msg "Stopping the coolest service ever unfortunately"

    # do something to kill the service or cleanup or nothing

    log_end_msg $?
    exit 0
    ;;
  *)
    echo "Usage: /etc/init.d/<your script> {start|stop}"
    exit 1
    ;;
esac



That's it 


Another way (but hackish) I used to do on an embedded system (but because that was not a debian, so beware, it seems more simple but an update of the system might screw it up) is to modify the /etc/profile.