I needed this feature to run a "read-only" mount for windows file system on startup (because I always hibernate Windows, so Ubuntu can't mount it "read-write" by default on startup)
1- Write the script in a file and save it in /etc/init.d
sudo gedit /etc/init.d/my_script
2- make the file executable
chmod +x /etc/init.d/my_script
3- add the script to rc.d files
sudo update-rc.d my_script defaults
And .... it's done.
There is a GUI tool to edit the rc.d called Boot-Up Manager (bum) , but I haven't try it. It can be found here
Note: Many thanks to Ahmad Amr for adding me as a contributer in this blog .....