Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been getting problems when trying to create a startup script in Ubuntu 9.04. I followed this guide but it didn't work: http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/

I followed the guide and created a script to see if it worked:

#This script is called test    
#!/bin/bash
#Startup Firefox
firefox&

I also attempted with #!/bin/sh, but it appeared to have the same problem.

After I created the file "test" in /etc/init.d, I typed this into the terminal:

ubuntuUser@ubuntu:~$ sudo update-rc.d test defaults

but I get this error:

ubuntuUser@ubuntu:~$ sudo update-rc.d test defaults
update-rc.d: warning: /etc/init.d/test missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
 System startup links for /etc/init.d/test already exist.

I did not know what was LSB and ignored it and typed this line in:

ubuntuUser@ubuntu:~$ sudo chmod +x /etc/init.d/test

After that, I restarted my computer, but it did not work.

The problem is that I do not know if it's the "Missing LSB information" that is preventing my script to boot at startup, if it's the way I wrote my startup script, or if I'm doing this entirely wrong.

I guess the main questions are if I am using the wrong guide, and how do I make the startup script that?

share|improve this question
add comment

4 Answers

First off, the script should start with the hashbang line:

#!/bin/bash
# All other lines should follow this one.

The LSB error relates to this block that's on all the system init scripts

### BEGIN INIT INFO
# Provides:          defaultdaemon
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INF

I haven't used update-rc.d before, but a quick look at the man page indicates that the default is S20 - this is the sequence in the boot that the script will run (where 1 earliest, and 99 is highest). As a general rule of thumb, this should be 99 unless you know otherwise, since what you're starting may depend on other services - mail, networking, syslog etc.

When you say the script doesn't work, what behaviour did you expect? This script is trying to start firefox while the machine is booting, it won't start it when users login.

You can set applications like firefox to run on login from the startup applications in the menu.

share|improve this answer
add comment

I followed the guide and created a script to see if it worked:

#This script is called test
#!/bin/bash

The "hashbang" line must be the first line in any script. If the guide suggested otherwise, choose a different guide.

I did not know what was LSB and ignored it

So, what happened when you read and understood the documentation update-rc.d pointed you to?

share|improve this answer
add comment

It sounds like you want to start programs after you log in. You should probably use this:

http://www.linuxscrew.com/2007/08/09/autostart-programs-in-ubuntu/

Otherwise, the script will try to run before X starts, and it's not going to work.

For more info about how linux boots check out: http://www.losurs.org/docs/linuxinit

share|improve this answer
add comment

LSB is Linux Standard Base. Take a look at the Debian wiki page that the warning recommended. There's lots of good information on it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.