MathMonkeyMan parent
I've worked with init.d style init systems that had those features using special comments and sourced helper functions, but I bet if you wanted to do it all properly you'd end up with something like systemd. Or GNU Shepherd!