> Date: Tue, 9 Mar 1999 09:13:05 -0800 (PST)
> From: Michael J. Rensing <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: Any HPUX administrators?

> I had already downloaded and compiled ssh successfully. My main
> 'installation' question is: How are people installing sshd to run each
> time the system is re-booted? I want the daemon to come up
> automatically whenever it crashes, or the system is re-booted. I could
> put it in the /etc/inittab file, or I could configure it completely
> with startup scripts in the various rc files. The problem is that I
> don't know much about the rc methods under HP, and I'd like to know
> what the conventions are. Has anyone done it this way?

This would be more the topic for a general UNIX mailing list.

You basically do the same thing you would do when adding any daemon, copy
another daemon's rc script and modify it for the new daemon.

This is the format for an HP-UX 10.X rc script.

/sbin/init.d/sshd:
#!/sbin/sh
export PATH=/sbin:/usr/sbin:/usr/bin

rval=0
set_return() {
        x=$?
        if [ $x -ne 0 ]; then
                echo "EXIT CODE: $x"
                rval=1  # always 1 so that 2 can be used for other reasons
        fi
}


case $1 in
start_msg)
        echo "Start secure shell daemon"
        ;;

stop_msg)
        echo "Stopping secure shell daemon"
        ;;
'start')
        if [ -f /etc/rc.config ] ; then
                . /etc/rc.config
        else
                echo "ERROR: /etc/rc.config defaults file MISSING"
        fi


        if [ "$SSHD" -eq 1 -a -x /opt/ssh/sbin/sshd ] ; then
                /opt/ssh/sbin/sshd $SSHD_ARGS && echo "sshd"
                set_return
        else
                rval=2
        fi      
        ;;

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

        #
        # Determine PID of process(es) to stop
        #
        if [ "$SSHD" -ne 1 ] ; then
            rval=2
        else
            if [ -r /var/run/sshd.pid ]; then
                if kill -TERM `cat /var/run/sshd.pid`; then
                        echo "sshd stopped"
                else
                        rval=1
                        echo "Unable to stop sshd"
                fi
            else
                rval=1
                echo "Unable to stop sshd (no pid file)"
            fi
        fi
        ;;

*)
        echo "usage: $0 {start|stop}"
        rval=1
        ;;
esac

exit $rval

Then create a link at the appropriate run level.

lrwxr-xr-x   1 root       sys             17 Apr  1  1998
/sbin/rc2.d/S950sshd@ -> /sbin/init.d/sshd

Benjamin J. Stassart
------------------------------------------------+
 A great many people think they are thinking    |
 when they are merely rearranging their         |
 prejudices                                     |

Reply via email to