Starting a service after all other services with init script

Hello,

I’m creating an OpenSuse based embedded system that mostly consists of a Qt/Embedded application – since it should function as an appliance, I want to have it boot, then immediately start that application without user intervention.

The only way I’m aware of of doing this with OpenSuse is to create a custom init script. I have done so, using /etc/init.d/skelton as a basis. It pretty much just consist of an INIT INFO section, followed by an invokation of another bash script only when the init script is called with the “start” argument.

The Qt/E program is run from this other bash script (started from the init script), which runs it in an infinite loop. This is so that my application can be restarted – if the application creates a “restart” file in /tmp/, which the script checks for the presence of, we know to go through another iteration of the loop when the program ends - otherwise we break out of the loop, because it was intended for us to finish the program.

All of this is not ideal for two reasons:

1.It causes the init script to never return, so the system is never properly initialised. Thus, we don’t have any spare gettys to work with if we need to.
2.I cannot get my services to start after all other services. I have specified that $ALL services are required to be started before my service, and this worked for a while, but no longer does. I’m not sure what I might have done to stop it from working, or if the fact that my service started after others for a time was a fluke. I initialised my service with “chkconfig --add my_service”.

Now, my service starts somewhere in the middle of other services, which is unacceptable – it stops important services like smartd from starting, or it cannot start because it itself is directly dependent on other uninitialised services.

Could someone either :

a. suggest an alternative approach that has the desired effect of invoking my application after all system services have been started.

or

b. suggest a way of adopting my current basic approach so that at least my application is started last as a service – that wouldn’t get me back my gettys, but it’s something I could live with.

Any help is greatly appreciated,

Regards,
Sternocera

$ALL ought to work. What is the sequencing in the /etc/init.d/rc5.d directory for example? If it has moved in front of some other services, have you done a SuSEconfig to restore the required sequence?

ken_yap,

The machine on which I’m doing all of this is not immediately available, so bear with me.

This machine doesn’t have a window manager, and has a default run level of 3.

I tried renaming the symbolic links in /etc/init.d/rc3.d, but that didn’t help.

have you done a SuSEconfig to restore the required sequence?

No, what’s that? How should I go about doing that? I’ve just been running “chkconfig --add my_service” or “insserv /etc/init.d/my_service”, or changing runlevels for services in yast2.

Regards,
Sternocera

SuSEconfig is the utility that is usually run behind the scenes by YaST to rebuild derived config files (from sysconfig), rebuild ldconfig cache, fonts, fix up runlevel symlinks and other thing whenever YaST does something that alters the config, like installing new software. You can run it manually too.

Renaming the symlinks doesn’t work on SUSE because they are automatically generated from the dependency info at the top of the init files. And it’s SuSEconfig that can fix up the sequence.

Nope, running SuSEconfig doesn’t seem to have any decernable effect.

Here’s my init script in its entirety:

#!/bin/sh

BEGIN INIT INFO

Provides: My application

Required-Start: $ALL

Default-Start: 3 5

Default-Stop: 0 1 2 6

Short-Description: My application

Description: My application

END INIT INFO

case “$1” in
start)
cd /home/sternocera/my_application
echo “Starting my application”
./init_my_application.sh
esac

. /etc/rc.status
rc_reset

Does that shine any light on it?
Thanks,
Sternocera

I cut and pasted your code into /etc/init.d/bar, changing only your line Provides: to

Provides: bar

and then did:

chkconfig --set bar on

Result was that in /etc/init.d/rc3.d, S21bar was linked to …/bar and that is correct because S21 is the last number in the sequence, only tied with stopblktrace.

insserv bar

had exactly the same effect. So your script ought to work. Maybe you should use a single word instead of My application in Provides: ?

Result was that in /etc/init.d/rc3.d, S21bar was linked to …/bar and that is correct because S21 is the last number in the sequence, only tied with stopblktrace.

Yes, I too find that. However, the service actually isn’t started in the desired order. I think that this is something peculiar to OpenSuSE.

Ahhh!

Thanks,
Sternocera

I have set RUN_PARALLEL to no in /etc/sysconfig/boot - this solves the problem.

That said, it was ostensibly working before, when RUN_PARALLEL was set to yes, so who knows what sort of fluke may have been occurring before, or if, indeed, the fact that it’s working now is a fluke.

Well…I guess it’ll have to do!

Thanks,
Sternocera

Sounds like RUN_PARALLEL isn’t quite fully debugged.

Run Parallel had more bugs in it than a stable :))


Marius from IT services

You may note that this is a 8 year old thread