Operating System - HP-UX
1833904 Members
1869 Online
110063 Solutions
New Discussion

Question about setting a program to startup automatically

 
fg_1
Trusted Contributor

Question about setting a program to startup automatically

Hi everyone,

I have a question about starting up an application automatically. I am fully aware that when you want to start up an application at boot time that you have to have a corresponding /etc/rc.config.d file for the app you want to start and set it to 1.

With that being said, i am attaching a script which is the S777netbackup startup script from my system's /sbin/init.d directory and what I want to know is how i can input a section into this script which will check a variable at startup time that the file exist in /etc/rc.config.d for startup of this application automatically.

example:

/etc/rc.config.d/netbackup

RUN_NETBACKUP=1

If I have this file in place in the rc.config.d directory how can I put something into the S777netbackup script that will allow it to read this other file in rc.config.d and startup the application automatically.

Sorry for the long post.

fg.
4 REPLIES 4
Sridhar Bhaskarla
Honored Contributor

Re: Question about setting a program to startup automatically

Hi,

I am not writing the script portion as you know how to write it.

You just need to put a check in your netbackup init.d script to see if RUN_NETBACKUP in rc.config.d/netbackup has been set to 1. If so, run your startup|shutdown command otherwise exit.

Take an example script (like cron) and see how it has been setup and you will get a good idea.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Brian M Rawlings
Honored Contributor

Re: Question about setting a program to startup automatically

Check other S###xxxxx start scripts in /sbin/rc2.d or wherever. Most of them check for the existence of a file in /etc/rc.config.d, and check the go/no-go parameter if it exists.

It should be simple to add more or less the same commands into the top of your script, to basically:

if exists,
then
if run=1
then continue
else exit
else continue
continue...

Are you looking for an actual working version of your script back that does this? I don't have time right now, but maybe later, let me know if this helps, or if that's what you are looking for.

Regards, --bmr
We must indeed all hang together, or, most assuredly, we shall all hang separately. (Benjamin Franklin)
Ian Dennison_1
Honored Contributor

Re: Question about setting a program to startup automatically

Here's the bit of code you need,...

if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi

(Stolen from /sbin/init.d/sendmail).

The above command looks for /etc/rc.config.d/[script name] ('netbackup' in your case) and then runs it to load the variables set.

After that variable is loaded, you can interrogate it within the start script.

#!/sbin/sh
# $Header: /kahlua_src/web/server/etc/webadmin 72.1 1999/09/16 03:51:04 lancer Exp $
# WebAdmin application server configuration.
#
# WEBADMIN: Set to 1 to start the WebAdmin application server.
#
WEBADMIN=0

(Example stolen from /etc/rc.config.d/webadmin)

Create your script in the file /sbin/init.d/netbackup, perform an 'ln -s' command to link it into /sbin/rc3.d/S[999]netbackup and /sbin/rc2.d/K[111]netbackup.

Easy peasy! Share and Enjoy! Ian
Building a dumber user
Dave La Mar
Honored Contributor

Re: Question about setting a program to startup automatically

fg -
I know this is more and less than what you are asking, but I am attaching the doc we used for starting a process.
We found this very straight forward and you can literally call any script. In your case, maybe one to perform the dependency checks you require.
Also note in the document, the non destructive way to test your SXXX script for errors.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."