Hi,
You can put your script in /etc/init.d and create a symlink in rc3.d (or rc5.d if it runs only on X):
Code:
ln -s /etc/init.d/script.sh /etc/init.d/rc3.d/SXXscript
Note that XX is a number specifying the order that the script will be executed. If XX=99 it will be executed after all the other scripts in runlevel 3. You can also use another symlink using K instead of S in the above command, to stop your script at shutdown.
Regards