Well, there are a couple more steps in addition to copying it over, but mainly it's just creation of symbolic links. Here's the contents of my vnc script:
Code:
#!/bin/bash
# description: Start or kill a vnc session for use in remote administration
# on startup and shutdown.
. /etc/init.d/functions
# See how we were called.
case "$1" in
start)
# Start the session as vnc_user
action $"Starting VNC session: " 'su -l vnc_user -c "/usr/local/bin/vncserver -depth 16 -geometry 1024x768"'
;;
stop)
# Stop the session
action $"Killing VNC session: " 'su -l vnc_user -c "/usr/local/bin/vncserver -kill :1"'
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
esac
exit 0
I copied that script to /etc/rc.d/init.d as a file named vnc_session, and made it executable. The script uses some bash functions provided by Red Hat (the /etc/init.d/functions business and the 'action' command).
Now comes the moderately complicated part. The complication comes solely from describing how the boot process works.
Assuming you use Red Hat:
In /etc/rc.d you should see a number of other rcX.d directories (where X = 1-6). The X represents the runlevel of your system. What you need to do is create specially named symbolic links in those directories to your script. To be safe, you probably ought to put links in rc3.d, rc4.d, and rc5.d. Go to one of those directories and get a file listing. You'll see that pretty much everything is a symbolic link to a file in /etc/rc.d/init.d, and that all the links start with either an S or a K followed by a two digit number. Create both the S and the K links for you script with something like:
Code:
ln -s ../init.d/script_name S98script_name
ln -s ../init.d/script_name K01script_name
The S tells init to execute your script with the argument "start" on the command line when the system enters the runlevel of the directory (i.e. rc3.d = runlevel 3, rc5.d = runlevel 5). The number after the S tells init what the order should be for the script. In other words, since we used 98, the script will execute next-to-last (it's ok to have multiple links with the same number). Similarly, the K link tells init to call your script with a "stop" argument on the command line, and the 01 tells init to call the script right off the bat when leaving the runlevel.
I'll double-check that, but I'm fairly certain that's the organization of those directories. If I'm fuzzy about anything, it would be when the K links are used.
As for the script being located in your root account's home directory, I doubt that's a problem.