File rcdropbear of Package dropbear

#!/bin/sh
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# Startup script for Dropbear
#
# /etc/init.d/dropbear
#
# and its symbolic link
# /usr/sbin/rcdropbear
#
### BEGIN INIT INFO
# Provides:             dropbear
# Required-Start:       $network $remote_fs
# Required-Stop:        $network $remote_fs
# Default-Start:        3 5
# Default-Stop:         0 1 2 6
# Short-Description:    Dropbear
# Description:          Dropbear is a relatively small SSH 2 server.
### END INIT INFO

# Note on runlevels:
# 0 - halt/poweroff                     6 - reboot
# 1 - single user                       2 - multiuser without network exported
# 3 - multiuser w/ network (text mode)  5 - multiuser w/ network and X11 (xdm)

. /etc/rc.status

DROPBEAR_BIN="/usr/sbin/dropbear"
DROPBEAR_LOCKFILE="/var/run/dropbear.pid"
DROPBEAR_SYSCONFIG="/etc/sysconfig/dropbear"
DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key"
DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key"


test -x $DROPBEAR_BIN || { echo "$DROPBEAR_BIN not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi; }

# Check for existence of sysconfig file and read it
if [ -r "$DROPBEAR_SYSCONFIG" ]; then
	. "$DROPBEAR_SYSCONFIG"
fi

# Reset status of this service
rc_reset

case "$1" in
    start)
        echo -n "Starting Dropbear "
        if [ ! -r "$DROPBEAR_DSSKEY" ] || [ ! -r "$DROPBEAR_RSAKEY" ]; then
            $0 keygen
        fi

        startproc -p "$DROPBEAR_LOCKFILE" "$DROPBEAR_BIN" $OPTIONS

        # Remember status and be verbose
        rc_status -v
    ;;
    stop)
        echo -n "Shutting down Dropbear "
        killproc -p "$DROPBEAR_LOCKFILE" -TERM "$DROPBEAR_BIN"
        rc_status -v
    ;;
    try-restart)
        ## Do a restart only if the service was active before.
        $0 status
        if test $? = 0; then
            $0 restart
        else
            rc_reset        # Not running is not a failure.
        fi
        rc_status
    ;;
    restart|reload)
        $0 stop
        $0 start
        rc_status
    ;;
    status)
        echo -n "Checking for Dropbear "
        checkproc -p "$DROPBEAR_LOCKFILE" "$DROPBEAR_BIN"
        rc_status -v
    ;;
    keygen)
        echo "Creating keys for Dropbear "
        if [ ! -r "$DROPBEAR_DSSKEY" ]; then
            dropbearkey -t dss -f "$DROPBEAR_DSSKEY"
        fi
        if [ ! -r "$DROPBEAR_RSAKEY" ]; then
            dropbearkey -t rsa -f "$DROPBEAR_RSAKEY"
        fi
        rc_status
    ;;
    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|reload|keygen}"
        exit 1
        ;;
esac
rc_exit
openSUSE Build Service is sponsored by