Hello,
Quote:
How would I create a file to autostart some commands?
|
like a bash script
Quote:
Where do I place this file?
|
in a init.d directory which is located somewhere in /etc
Quote:
Does it need a special name?
|
No
Quote:
How/where to I setup the symlink stuff?
|
Very interesting question
First your symlink need a special name. For example if you file in init.d is named foo, then you will have to name his symlinks S90foo if it's a start script and K20foo if it's a kill script. So the rule is the following: for a start script, the symlink keeps the same name with a prefix which is S and a number. The S means that "start" will be passed as an argument to your script and the number is to determine the order to run scripts. So for a kill script that's the same rule and the prefix is a K.
After this explanation, I have to add that your script can do both: start or kill a process. For example, my devfsd start/kill script:
Code:
case "$1" in
start)
echo "Starting devfs daemon..."
loadproc /sbin/devfsd /dev
;;
stop)
echo "Stopping devfs daemon..."
killproc /sbin/devfsd
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
statusproc /sbin/devfsd
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Now the problem is to know where to do the symlink... For that you need to know the runlevel you boot (have a look at /etc/inittab file to know it... but that's probably 5). So imagine that when you, your runlevel is 5 and you want to add a startup script. Then put it in init.d directory and go in rc5.d directory. Then type the following:
Code:
ln -s ../init.d/myscript S90myscript
If your script run a background task that you want properly quit when you shutdown your computer, then do the same in rc6.d (for reboot) and rc0.d (for shutdown) with kill argument.
Hope this help you
Oliv'