summaryrefslogtreecommitdiffstats
path: root/contrib/caldera/sshd.init
diff options
context:
space:
mode:
authorTim Rice <tim@multitalents.net>2001-04-26 22:50:48 -0700
committerTim Rice <tim@multitalents.net>2001-04-26 22:50:48 -0700
commita8c7a62ad4a2401e1200cef2c180d34f95aaf7cc (patch)
tree2a51426e350054fb1bc66d9289312101b90e9c2c /contrib/caldera/sshd.init
parentbb34625b6c417d40571acc166786ba0addf728de (diff)
- (tim) update contrib/caldera files with what Caldera is using.
<sps@caldera.de>
Diffstat (limited to 'contrib/caldera/sshd.init')
-rwxr-xr-xcontrib/caldera/sshd.init206
1 files changed, 116 insertions, 90 deletions
diff --git a/contrib/caldera/sshd.init b/contrib/caldera/sshd.init
index 17643391..e60f8afe 100755
--- a/contrib/caldera/sshd.init
+++ b/contrib/caldera/sshd.init
@@ -1,99 +1,125 @@
-#! /bin/sh
+#! /bin/bash
#
-# Generic network daemon RC script. If installed as /etc/rc.d/init.d/foobar,
-# it source /etc/sysconfig/daemons/foobar and looks at the
-# variable definitions (Bourne shell syntax). Variables marked with an
-# asterisk are required.
+# $Id: sshd.init,v 1.2 2001/04/27 05:50:50 tim Exp $
#
-# * IDENT=sshd
-# DESCRIPTIVE="@OPENSSH_VERSION@"
-# * DAEMON=/usr/sbin/sshd
-# DAEMON_ARGS="-p some_other_port"
-# ONBOOT=yes
+### BEGIN INIT INFO
+# Provides:
+# Required-Start: $network
+# Required-Stop:
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Description: sshd
+# Bring up/down the OpenSSH secure shell daemon.
+### END INIT INFO
#
+# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
+# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
+# Modified for OpenLinux by Raymund Will <ray@caldera.de>
-# Source networking configuration.
-. /etc/sysconfig/network
-
-# Check that networking is up.
-[ ${NETWORKING} = "no" ] && exit 0
-
-# Source function library, check sysconfig/daemon file and source it.
-. /etc/rc.d/init.d/functions
-
-[ -x $DAEMON ] || exit 0
-
-# Some functions to make the below more readable
-KEYGEN=/usr/bin/ssh-keygen
-RSA1_KEY=/etc/ssh/ssh_host_key
-RSA_KEY=/etc/ssh/ssh_host_rsa_key
-DSA_KEY=/etc/ssh/ssh_host_dsa_key
-PID_FILE=/var/run/sshd.pid
-do_rsa1_keygen() {
- if ! test -f $RSA1_KEY ; then
- echo -n "Generating SSH1 RSA host key: "
- if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then
- echo "RSA1 key generation success"
- else
- echo "RSA1 key generation failure"
- exit 1
- fi
- fi
-}
-do_rsa_keygen() {
- if ! test -f $RSA_KEY ; then
- echo -n "Generating SSH2 RSA host key: "
- if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then
- echo "RSA key generation success"
- else
- echo "RSA key generation failure"
- exit 1
- fi
- fi
-}
-do_dsa_keygen() {
- if ! test -f $DSA_KEY ; then
- echo -n "Generating SSH2 DSA host key: "
- if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then
- echo "DSA key generation success"
- else
- echo "DSA key generation failure"
- exit 1
- fi
- fi
+NAME=sshd
+DAEMON=/usr/sbin/$NAME
+# Hack-Alert(TM)! This is necessary to get around the 'reload'-problem
+# created by recent OpenSSH daemon/ssd combinations. See Caldera internal
+# PR [linux/8278] for details...
+PIDF=/var/run/$NAME.pid
+NAME=$DAEMON
+
+_status() {
+ [ -z "$1" ] || local pidf="$1"
+ local ret=-1
+ local pid
+ if [ -n "$pidf" ] && [ -r "$pidf" ]; then
+ pid=$(head -1 $pidf)
+ else
+ pid=$(pidof $NAME)
+ fi
+
+ if [ ! -e $SVIlock ]; then
+ # no lock-file => not started == stopped?
+ ret=3
+ elif { [ -n "$pidf" ] && [ ! -f "$pidf" ] } || [ -z "$pid" ]; then
+ # pid-file given but not present or no pid => died, but was not stopped
+ ret=2
+ elif [ -r /proc/$pid/cmdline ] &&
+ echo -ne $NAME'\000' | cmp -s - /proc/$pid/cmdline; then
+ # pid-file given and present or pid found => check process...
+ # but don't compare exe, as this will fail after an update!
+ # compares OK => all's well, that ends well...
+ ret=0
+ else
+ # no such process or exe does not match => stale pid-file or process died
+ # just recently...
+ ret=1
+ fi
+ return $ret
}
-# See how we were called.
+# Source function library (and set vital variables).
+. @SVIdir@/functions
+
case "$1" in
- start)
- # Create keys if necessary
- do_rsa1_keygen
- do_rsa_keygen
- do_dsa_keygen
-
- # Start daemons.
- [ ! -e $LOCK ] || exit 1
- echo -n "Starting $SUBSYS services: "
- start-stop-daemon -S -n $IDENT -x $DAEMON -- $DAEMON_ARGS
- sleep 1
- echo .
- touch $LOCK
- ;;
- stop)
- # Stop daemons.
- [ -e $LOCK ] || exit 0
- echo -n "Stopping $SUBSYS services: "
- start-stop-daemon -K -n $IDENT -x $DAEMON
- echo
- rm -f $LOCK
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- *)
- echo "Usage: $SUBSYS {start|stop|restart}"
- exit 1
+ start)
+ [ ! -e $SVIlock ] || exit 0
+ [ -x $DAEMON ] || exit 5
+ SVIemptyConfig @sysconfdir@/sshd_config && exit 6
+
+ if [ ! \( -f @sysconfdir@/ssh_host_key -a \
+ -f @sysconfdir@/ssh_host_key.pub \) -a \
+ ! \( -f @sysconfdir@/ssh_host_rsa_key -a \
+ -f @sysconfdir@/ssh_host_rsa_key.pub \) -a \
+ ! \( -f @sysconfdir@/ssh_host_dsa_key -a \
+ -f @sysconfdir@/ssh_host_dsa_key.pub \) ]; then
+
+ echo "$SVIsubsys: host key not initialized: skipped!"
+ echo "$SVIsubsys: use ssh-host-keygen to generate one!"
+ exit 6
+ fi
+
+ echo -n "Starting $SVIsubsys services: "
+ ssd -S -x $DAEMON -n $NAME -- $OPTIONS
+ ret=$?
+
+ echo "."
+ touch $SVIlock
+ ;;
+
+ stop)
+ [ -e $SVIlock ] || exit 0
+
+ echo -n "Stopping $SVIsubsys services: "
+ ssd -K -p $PIDF -n $NAME
+ ret=$?
+
+ echo "."
+ rm -f $SVIlock
+ ;;
+
+ force-reload|reload)
+ [ -e $SVIlock ] || exit 0
+
+ echo "Reloading $SVIsubsys configuration files: "
+ ssd -K --signal 1 -q -p $PIDF -n $NAME
+ ret=$?
+ echo "done."
+ ;;
+
+ restart)
+ $0 stop
+ $0 start
+ ret=$?
+ ;;
+
+ status)
+ _status $PIDF
+ ret=$?
+ ;;
+
+ *)
+ echo "Usage: $SVIscript {[re]start|stop|[force-]reload|status}"
+ ret=2
+ ;;
+
esac
-exit 0
+exit $ret
+