When I last looked, the package to pick up was
/pub/Linux/system/Daemons/SysVinit-2.50.tgz from
sunsite.unc.edu or a mirror. It includes a copy of powerd.c,
shutdown.c, an initd that understands what to do with SIGPWR and
can handle powerfail and powerokwait entries in the inittab file.
Of course, by now, I'm sure much newer versions are available. Whatever you get might differ from the description here, but will probably adhere to the overall philosophy.