October 29, 2003

OpenSSH init.d script for Solaris    [ Software ]

Needed to hack up an improved init script for OpenSSH on Solaris - see below for details.

#!/bin/sh

DAEMON=/usr/local/sbin/sshd
PIDFILE=/usr/local/etc/sshd.pid

#pid=`/usr/bin/ps -e | /usr/bin/grep sshd | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
pid=`test -f ${PIDFILE} && cat ${PIDFILE}`

case "$1" in

'start')
        if [ -x ${DAEMON} ]; then
                echo "Starting OpenSSH daemon"
                ${DAEMON} &
        else
                echo "${DAEMON} does not exist or is not executable!"
        fi
        ;;

'stop')
        echo "Stopping OpenSSH daemon"
        if [ "${pid}" != "" ]
        then
                /usr/bin/kill ${pid}
        fi
        ;;

'restart')
        echo "Restarting OpenSSH daemon"
        if [ "${pid}" != "" ]
        then
                /usr/bin/kill -HUP ${pid}
        fi
        ;;

*)
        echo "usage: /etc/init.d/sshd {start|stop|restart}"
        ;;

esac
exit 0
Posted by edobbs at October 29, 2003 11:54 AM