This has to do with the way init works.
/etc/rc2.d should contain links to your script in /etc/init.d/
The S in front if it will cause initd to execute the script with the argument 'start'. If there is a k in front of it will will have 'stop' sent to it. The number are the order in which they are called, lowest to highest.
Look at some of the other scripts in /etc/init.d/ for examples of how you should right your own.
you can find some examples on the web about writing these, check out:
http://www.debian-administration.org/articles/28