James Lewis designed this AVR based power controller for the Raspberry Pi that can safely shutdown the Pi:
Raspberry Pi Soft Power Controller
The total circuit includes an AVR microcontroller, a near-zero current LDO, and a switching (buck) supply. My current design draws about 350nA when Vin is 9V. The AVR controls power to the Raspberry Pi. Two GPIO pins are used. One for the AVR to initiate a shutdown and one for Raspberry Pi to tell AVR after filesystem has been unmounted.
The design files and source are shared on GitHub: