I'm building a shutdown button for my Raspberry pi, and for that I have a python script that needs to change a GPIO pin on my Raspberry Pi just before the system runs the halt script. Now Raspbian uses LSB headers to determine the order in which scripts are run at shutdown, but I can't for the life of me figure out what to put in the header so that the script will run AFTER everything except /etc/init.d/halt has run. The problem right now is that the script runs too soon (it always installs at K01xx), thus cutting the power before all other services have shut down properly. I tried setting a custom priority as described in the guide here: http://www.debuntu.org/how-to-managing-services-with-update-rc-d/, but that does nothing as the command just says using dependency based boot sequencing, with the end result being the same as before. I tried manually renaming the K01xx script in /etc/rc0.d to K09xx, so that it would be the last one before the halt command in the directory. But that had no effect either. Any suggestions?My init.d script:#! /bin/sh### BEGIN INIT INFO# Provides:          shutdown# Required-Start:    # Required-Stop:# Default-Start: 2 3 4 5# Default-Stop: 0# Short-Description: Detect shutdown button### END INIT INFOPATH=/sbin:/usr/sbin:/bin:/usr/bin. /lib/init/vars.sh. /lib/lsb/init-functionsdo_start() {    if [ -x /home/pi/bin/shutdown.py ]; then            [ $VERBOSE != no ] && log_begin_msg Starting listening for shutdown button        python /home/pi/bin/shutdown.py &        ES=$?        [ $VERBOSE != no ] && log_end_msg $ES        return $ES    fi}do_stop() {    if [ -x /home/pi/bin/shutdown_pin.py ]; then        [ $VERBOSE != no ] && log_begin_msg Lowering pin for complete shutdown        python /home/pi/bin/shutdown_pin.py        ES=$?        [ $VERBOSE != no ] && log_end_msg $ES    fi}case $1 in    start)    do_start        ;;    restart|reload|force-reload)        echo Error: argument '$1' not supported >&2        exit 3        ;;    stop)    do_stop        ;;    *)        echo Usage: $0 start|stop >&2        exit 3        ;;esac
How do I run a script just before halt using LSB headers on Raspbian
shutdown;raspbian;lsb