0

I'd like my openSuse 11.1 server to run a small shell script on startup. I've created a the script and put a symbolic link to the script in /etc/init.d/rc5.d/. Yet, the script does not get executed.

This is the script I am trying to run:

#!/bin/bash
#monitor RAID array
/sbin/mdadm --monitor --daemonize --mail=adrian@linuxplug.fli4l /dev/md0 /dev/md1 /dev/md2 /dev/md3
#start SVN server
/usr/bin/svnserve -d

The script works fine when I run it myself from the command line (svn server and mdadm are daemonized as expected). But it does not seem to be started when rebooting the server.

This might help you figure out what I am doing wrong:

linuxplug:~ # ls -l /etc/init.d/rc5.d/exe*
lrwxrwxrwx 1 root root 25 May 22 11:43 /etc/init.d/rc5.d/executeatstartup.sh -> /root/executeatstartup.sh
linuxplug:~ # ls -l /root/executeatstartup.sh
-rwxr-xr-x 1 root root 172 Apr 12 13:43 /root/executeatstartup.sh
linuxplug:~ # which svnserve
/usr/bin/svnserve

What am I doing wrong?

Edit: I've renamed the link to the shell script as follows:

linuxplug:~ # ls -l /etc/init.d/rc5.d/    
lrwxrwxrwx 1 root root 25 May 22 12:03 S99executeatstartup -> /root/executeatsta
    rtup.sh

However, the script still isn't run on startup.

Adrian Grigore
  • 1,072
  • 3
  • 21
  • 34

7 Answers7

1

you should have your link named S99something, where S stands for starting, and 99 stands for the order in which the scripts in that directory are started. see the other link in that directory...

Besides: you may want to rework the script to honour start / stop arguments, and add a K99something symlink to make sure the services are properly stop when leaving this run level.

Vincent De Baere
  • 1,793
  • 10
  • 10
1

Have you allready followed the steps listed on the opensuse web site? That should definitely work.

There is a pretty good explanation at Cool Solutions as well

Vincent De Baere
  • 1,793
  • 10
  • 10
1

Have you tried adding a call to the script in your /etc/init.d/boot.local? Try it and see if that works better. There are several other boot.* files that are run at different parts of the startup.

Stefan Thyberg
  • 704
  • 1
  • 8
  • 15
0

You should put that commands in /etc/rc.local (or equivalent in opensuse)

initscripts must have a certain syntax. You can check one of them for an example, but what you need is /etc/rc.local

hayalci
  • 3,631
  • 3
  • 27
  • 37
  • There is no rc.local in opensuse. I've followed the tutorial at http://linux.derkeiler.com/Mailing-Lists/SuSE/2005-07/1773.html, but it still does not work. – Adrian Grigore May 22 '09 at 12:13
0

There should definitely be a way to do what you want from the /etc/rc*. Another alternative you might want to look into is cron. With vixie-cron it's possible to specify tasks to run on reboot with the @reboot keyword in your crontab:

Instead of the first five fields, one of eight special strings may
appear:

string         meaning
------         -------
@reboot        Run once, at startup.
@yearly        Run once a year, "0 0 1 1 *".
@annually      (same as @yearly)
@monthly       Run once a month, "0 0 1 * *".
@weekly        Run once a week, "0 0 * * 0".
@daily         Run once a day, "0 0 * * *".
@midnight      (same as @daily)
@hourly        Run once an hour, "0 * * * *".

The above table is from a blog post by Jeremy Zawodny which I'm not allowed to post a link to as a new user. Search for "vixie-cron specify tasks on boot" on Google, and it's the first result.

As mentioned in the article, it's a great way to allows users to run commands at startup without granting them root access.

Mike Mazur
  • 6,133
  • 2
  • 20
  • 13
0

It's also worth checking /etc/inittab to ensire that you're booting into runlevel five by default, look for a line like:

id:2:initdefault:

That's from my debian laptop and shows that I boot into runlevel two by default (which is debian's default).

On RedHat derivatives (like openSuSE) runlevel five is the default when running X11, runlevel three is the default to boot to the console.

LapTop006
  • 6,496
  • 20
  • 26
0

Does opensuse have selinux? If so is it turned on and is the context of your script the same as the other start up scripts? Try getenforce to see if selinux in installed an turned on. Try ls -lZ /etc/init.d/rc5.d/ to see the scripts' contexts

Jason Tan
  • 2,752
  • 2
  • 17
  • 24