This can be very OS dependent. On my HPUX system, you would put a script in /sbin/init.d.
To start up a script at boot time, create a link in the run level directory that you want it to start up at. In my case that is runlevel 3. I would put a link in /sbin/rc3.d linked to the file in /sbin/init.d with an Sxxxfilename. Where xxx is a 3 digit number. and a Kxxxfilename in a lower level run level directory to kill the script as the box shuts down.
Here is an example:
cd /sbin/init.d
touch startup.sh # you would have a real script here.
cd /sbin/rc3.d
ln S723startup.sh /sbin/init.d/starup.sh
cd /sbin/rc2.d
ln K723startup.sh /sbin/init.d/startup.sh
You will need to look at another script in /sbin/init.d to see how to use the stop and start functionality for this to work. This should be a fairly common standard for most UNIX OSs. The directories may be different but the concept is vaild.