summaryrefslogtreecommitdiff
path: root/contrib/caldera/sshd.init
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-01-04 22:54:50 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-01-04 22:54:50 +0000
commit91c2a985f9d00247ba2fda6aebbffaeac609f328 (patch)
tree3088f4d4c8e1c7d49cd61918d31444739749dda7 /contrib/caldera/sshd.init
parentf1aa21f18f381b3dbc9c619699baa62298364072 (diff)
20010105
- (bal) contrib/caldera/ provided by Tim Rice <tim@multitalents.net>
Diffstat (limited to 'contrib/caldera/sshd.init')
-rwxr-xr-xcontrib/caldera/sshd.init99
1 files changed, 99 insertions, 0 deletions
diff --git a/contrib/caldera/sshd.init b/contrib/caldera/sshd.init
new file mode 100755
index 00000000..17643391
--- /dev/null
+++ b/contrib/caldera/sshd.init
@@ -0,0 +1,99 @@
+#! /bin/sh
+#
+# 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.
+#
+# * IDENT=sshd
+# DESCRIPTIVE="@OPENSSH_VERSION@"
+# * DAEMON=/usr/sbin/sshd
+# DAEMON_ARGS="-p some_other_port"
+# ONBOOT=yes
+#
+
+# 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
+}
+
+# See how we were called.
+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
+esac
+
+exit 0