LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Starting a self-built process at boot time (https://www.linuxquestions.org/questions/solaris-opensolaris-20/starting-a-self-built-process-at-boot-time-577814/)

daihard 08-17-2007 11:21 AM

Starting a self-built process at boot time
 
Hi.

I did a bit of Googling around but was not able to find a suitable answer, so here goes...

I compiled OpenSSH for Solaris 2.7. The "uname -a" commands yields the following.
Code:

SunOS sparc-dual7 5.7 Generic_106541-20 sun4u sparc SUNW,Ultra-250
I am now able to run sshd by simply execting the command as follows:
Code:

/usr/local/sbin/sshd -f /usr/local/etc/sshd_config
So far, so good. Now what I'd like to do is include the command as part of the startup process so the sshd daemon starts automatically at bootup. It would be as simple as adding the command to /etc/rc.local under Linux, but there's no such file under Solaris. There are a bunch of /etc/rc* directories where different startup scripts are stored depending upon the runlevel, but I'm not sure I should mess with them manually.

Any help would be appreciated.

TIA,
Dai

jlliagre 08-17-2007 04:28 PM

Put your start script in /etc/rc3.d/S99sshd

ADxD_7 08-29-2007 06:20 PM

Make sure your script has a

Code:

case "$1" in

start) (your command)

;;

stop)

;;

esac

Or something of the like or it wont start :)

jlliagre 08-29-2007 07:09 PM

I'm sorry to tell it will start even without that. The rc launcher does not parse the scripts expecting a structure, it just executes them.

Of course, using such a construction is more elegant, is the usual way it is done and allows to enhance the script to stop the service too.

ADxD_7 08-30-2007 06:57 PM

Really ? I always thought that it passed "start" to all the S ones and stop to all the K ones ?

From /etc/init.d/README

"File names in rc?.d directories are of the form [SK]nn<init.d filename>
where 'S' means start this job, 'K' means kill this job, and 'nn' is the
relative sequence number for killing or starting the job. When
executing each script in one of the /etc/rc[S0-6] directories, the
/sbin/rc[S0-6] script passes a single argument. It passes the argument
'stop' for scripts prefixed with 'K' and the argument 'start' for
scripts prefixed with 'S'. There is no harm in applying the same
sequence number to multiple scripts. In this case the order of
execution is deterministic but unspecified. It is recommended that
scripts be hard-linked from the same file stored in /etc/init.d/."

But I could be wrong

crisostomo_enrico 08-30-2007 07:14 PM

Yes, that's true. But it's also true that one script that receives whichever parameter can just ignore it: one thing is receiving, another thing is using.

Besides, if you respect that structure you can write only one script to start, stop, restart, etc. and using that parameter to switch between behaviours.

Bye,
Enrico.


All times are GMT -5. The time now is 04:37 PM.