I'm starting sshd version 1.x.x with a script in  /sbin/init.d/and the
usual associated symbolic links. This is HP-UX 10.20.

Below is the script I used to install it and the links, and the script
itself. It's cribbed from stuff I've used elsewhere, so some of the code
isn't used.

The path of the binary differs from the standard install a bit, you may
need to adjust that.

install script:
- - cut here - -
#!/usr/bin/sh -vx
cp sshd  /sbin/init.d/sshd
#
# start run level 2, number 900 kill run level 1 number 100
# are HP "do not care" numbers
#
cd /sbin/rc2.d
ln -s /sbin/init.d/sshd S900sshd
#
cd /sbin/rc1.d
ln -s /sbin/init.d/sshd K100sshd
#

- - cut here - -

/sbin/init.d/sshd
- - cut here - -
#!/sbin/sh
# 12-98 Albert Lunde start sshd
#

PATH=/sbin:/usr/sbin:/usr/bin
export PATH

rval=0
set_return() {
        x=$?
        if [ $x -ne 0 ]; then
                rval=$x
        fi
}

# Kill the named process(es).
# $1 = full pathname for process - matches first token in ps command listing
# $2 = kill option/signal

killproc() {
#
#      ps -ef is used to allow matching on full path
#      Use of column ranges with cut reduces ambiguity in parsing
#      tokens (old processes have date instead of time in ps -ef)
#      This is not very portable
#
       pid=`ps -ef | cut -c 9-14,48-120 | awk '{print"="$2"="$1"="}'\
           | egrep -e "^=$1=" | awk -F= '{print $3}'`
        if [ "X$pid" != "X" ]; then
                for p in $pid
                  do
                    if /usr/bin/kill $2 $p; then
                            /usr/bin/echo "$1 pid $p stopped"
                    else
                            rval=1
                            /usr/bin/echo "Unable to stop $1i pid $p" >&2
                    fi
                done
        #else
           # echo "No $1 processes found"  >&2
        fi
}

findproc() {
# Similar to killproc; check for existing process
#
       pid=`ps -ef | cut -c 9-14,48-120 | awk '{print"="$2"="$1"="}'\
           | egrep -e "^=$1=" | awk -F= '{print $3}'`
        if [ "X$pid" != "X" ]; then
            # process exists
            echo "Process $1 already exists pid=$pid"
            exit 1
        fi
}



case $1 in
start_msg)
        echo "Starting sshd v1 daemon"
        ;;

stop_msg)
        echo "Stopping sshd v1 daemon"
        ;;

'start')
        /opt/local/sbin/sshd1
        set_return

    ;;

'stop')
        # kill nicely, then kill hard
    killproc "/opt/local/sbin/sshd1" -TERM
    sleep 3
    killproc "/opt/local/sbin/sshd1" -9
    ;;

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

exit $rval
- - cut here - -



---
    Albert Lunde                      [EMAIL PROTECTED]

Reply via email to