To properly shutdown Raspberry Pi when ignition signal disappears, an electrical line was provided to notify the need to shutdown. The shutdown daemon, monitors this line (pin 13 on P1 header of Raspberry Pi). When this pin goes low, a shutdown command is issued.

Downlaod the daemon

Click here to download the shutdown daemon, or follow installation steps below:

Install the daemon

Enter home directory:

cd

Download the daemon:

curl -O -J "https://www.carberry.it/index.php?route=download/download/download&download_id=31"

Untar the file:

tar -xvf shutdown_d_1.1.tar

Create directory in /usr/local/bin:

sudo mkdir -p /usr/local/bin/carberry

Move directory to /usr/local/bin/carberry:

sudo mv shutdown_d /usr/local/bin/carberry/

Add execution rights:

chmod +x /usr/local/bin/carberry/shutdown_d/shutdown.sh

Add a new line to the /etc/rc.local before exit 0 line.
Edit:

sudo nano /etc/rc.local

Add:

/usr/local/bin/carberry/shutdown_d/shutdown.sh&
exit 0

System Reboot:

sudo reboot

Check daemon exexution

Check daemon execution:

ps aux | grep shutdown

You have to see something like this:

pi@raspberrypi ~ $ ps aux | grep shutdown
root      2058  0.4  0.2   2736  1188 ?        S    14:40   0:00 /bin/bash /usr/local/bin/carberry/shutdown_d/shutdown.sh
pi        2380  0.0  0.1   3568   832 pts/0    S+   14:42   0:00 grep --color=auto shutdown
pi@raspberrypi ~ $

Test the daemon

To test the daemon, take a wire, and jump toghether pin 13 and pin 25 of P1 connector on Raspberry Pi. Raspberry Pi will halt now!.