2 updated quoting
source | link

I have a Raspberry PI running the standard Raspbian distribution. I have this little C program that I need to run at the very end of the shutdown sequence. All it does is send a couple of logical high pulses on a GIPO output to a power supply to tell it to cut the power to the Raspberry board. The shutdown script should be called if, and only if, the system is being powered down but not when the PI is being rebooted or started up.

I have been trying and failing to use update-rc.d to do this. The way I understand the update-rc.d documentation what I have to do is:

  1. Copy my executable (poweroff.binpoweroff.bin), copy it to /sbin and give it the required permissions and a LSB header:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: poweroff
    # Required-Start:
    # Required-Stop:   $all
    # Default-Start:
    # Default-Stop:      0
    # Short-Description: Power off.
    # Description:       Send a power off signal to the PM board.
    # X-Interactive:     false
    ### END INIT INFO
    
    /sbin/poweroff.bin
    
    exit 0
    
  2. Create a script called poweroffpoweroff in /etc/init.d

  3. Run the command sudo update-rc.d poweroff stop 99 0 poweroff stop 99 0.

This will yield me a script: /etc/rc0.d/K99poweroff/etc/rc0.d/K99poweroff which will call /sbin/poweroff.bin/sbin/poweroff.bin if, and only if the system is being halted.

I have three questions:

  1. Whenever I run 'sudo update-rc.d poweroff stop 99 0 .'sudo update-rc.d poweroff stop 99 0 . it only results in a script called '/etc/rc0.d/K01poweroff'/etc/rc0.d/K01poweroff being created. What am I doing wrong? what happened to the 99?
  2. What is the significance of the start and stop options during run level 0? Should this script be a K99 or an S99? there seems little point in a start script in run level 0.
  3. Is run level 0 only used when shutting down? I.e if I do a 'shutdown -r now" does the computer get sent down to run level 0 and themthen back to run levelrunlevel 6?

I have a Raspberry PI running the standard Raspbian distribution. I have this little C program that I need to run at the very end of the shutdown sequence. All it does is send a couple of logical high pulses on a GIPO output to a power supply to tell it to cut the power to the Raspberry board. The shutdown script should be called if, and only if, the system is being powered down but not when the PI is being rebooted or started up.

I have been trying and failing to use update-rc.d to do this. The way I understand the update-rc.d documentation what I have to do is:

  1. Copy my executable (poweroff.bin), copy it to /sbin and give it the required permissions and a LSB header:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: poweroff
    # Required-Start:
    # Required-Stop:   $all
    # Default-Start:
    # Default-Stop:      0
    # Short-Description: Power off.
    # Description:       Send a power off signal to the PM board.
    # X-Interactive:     false
    ### END INIT INFO
    
    /sbin/poweroff.bin
    
    exit 0
    
  2. Create a script called poweroff in /etc/init.d

  3. Run the command sudo update-rc.d poweroff stop 99 0 .

This will yield me a script: /etc/rc0.d/K99poweroff which will call /sbin/poweroff.bin if, and only if the system is being halted.

I have three questions:

  1. Whenever I run 'sudo update-rc.d poweroff stop 99 0 .' it only results in a script called '/etc/rc0.d/K01poweroff' being created. What am I doing wrong? what happened to the 99?
  2. What is the significance of the start and stop options during run level 0? Should this script be a K99 or an S99? there seems little point in a start script in run level 0.
  3. Is run level 0 only used when shutting down? I.e if I do a 'shutdown -r now" does the computer get sent down to run level 0 and them back to run level 6?

I have a Raspberry PI running the standard Raspbian distribution. I have this little C program that I need to run at the very end of the shutdown sequence. All it does is send a couple of logical high pulses on a GIPO output to a power supply to tell it to cut the power to the Raspberry board. The shutdown script should be called if, and only if, the system is being powered down but not when the PI is being rebooted or started up.

I have been trying and failing to use update-rc.d to do this. The way I understand the update-rc.d documentation what I have to do is:

  1. Copy my executable (poweroff.bin), copy it to /sbin and give it the required permissions and a LSB header:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: poweroff
    # Required-Start:
    # Required-Stop:   $all
    # Default-Start:
    # Default-Stop:      0
    # Short-Description: Power off.
    # Description:       Send a power off signal to the PM board.
    # X-Interactive:     false
    ### END INIT INFO
    
    /sbin/poweroff.bin
    
    exit 0
    
  2. Create a script called poweroff in /etc/init.d

  3. Run the command sudo update-rc.d poweroff stop 99 0.

This will yield me a script: /etc/rc0.d/K99poweroff which will call /sbin/poweroff.bin if, and only if the system is being halted.

I have three questions:

  1. Whenever I run sudo update-rc.d poweroff stop 99 0 . it only results in a script called /etc/rc0.d/K01poweroff being created. What am I doing wrong? what happened to the 99?
  2. What is the significance of the start and stop options during run level 0? Should this script be a K99 or an S99? there seems little point in a start script in run level 0.
  3. Is run level 0 only used when shutting down? I.e if I do a 'shutdown -r now" does the computer get sent down to run level 0 and then back to runlevel 6?
1
source | link

Creating a shutdown only script with update-rc.d

I have a Raspberry PI running the standard Raspbian distribution. I have this little C program that I need to run at the very end of the shutdown sequence. All it does is send a couple of logical high pulses on a GIPO output to a power supply to tell it to cut the power to the Raspberry board. The shutdown script should be called if, and only if, the system is being powered down but not when the PI is being rebooted or started up.

I have been trying and failing to use update-rc.d to do this. The way I understand the update-rc.d documentation what I have to do is:

  1. Copy my executable (poweroff.bin), copy it to /sbin and give it the required permissions and a LSB header:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: poweroff
    # Required-Start:
    # Required-Stop:   $all
    # Default-Start:
    # Default-Stop:      0
    # Short-Description: Power off.
    # Description:       Send a power off signal to the PM board.
    # X-Interactive:     false
    ### END INIT INFO
    
    /sbin/poweroff.bin
    
    exit 0
    
  2. Create a script called poweroff in /etc/init.d

  3. Run the command sudo update-rc.d poweroff stop 99 0 .

This will yield me a script: /etc/rc0.d/K99poweroff which will call /sbin/poweroff.bin if, and only if the system is being halted.

I have three questions:

  1. Whenever I run 'sudo update-rc.d poweroff stop 99 0 .' it only results in a script called '/etc/rc0.d/K01poweroff' being created. What am I doing wrong? what happened to the 99?
  2. What is the significance of the start and stop options during run level 0? Should this script be a K99 or an S99? there seems little point in a start script in run level 0.
  3. Is run level 0 only used when shutting down? I.e if I do a 'shutdown -r now" does the computer get sent down to run level 0 and them back to run level 6?