I found this snippet of knowledge from the Raspberry Pi forum the other day when searching for a easy way to shutdown a RPi from a simple push button.
Open /boot/config.txt in your favorite Raspbian editor and add the following line:
You may need to add a pull-up resistor to the GPIO pin or add the instruction gpio_pull=up to the instruction. You can also leave out the gpio_pin and the system will default to GPIO3.
You can also monitor the RPi’s status by adding this line to config.txt:
GPIO27 will be high to indicate when the RPI is running or low when it is shut down.
There is more detailed information here: