What is the mechanism provided by the system?
The
/etc/inittab file is the mechanism provided by the system:
::restart:/etc/init.d/rc.shutdown
::restart:/sbin/init
::shutdown:/etc/init.d/rc.shutdown
Simply add your script:
::restart:/usr/local/sbin/myrestart
::restart:/etc/init.d/rc.shutdown
::restart:/sbin/init
::shutdown:/usr/local/sbin/myshutdown
::shutdown:/etc/init.d/rc.shutdown