Damien Miller | 294df78 | 1999-11-23 10:11:29 +1100 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # Copyright (c) 1995-1998 SuSE GmbH Nuernberg, Germany. |
| 3 | # |
| 4 | # Author: Chris Saia <csaia@wtower.com> |
| 5 | # |
| 6 | # /sbin/init.d/sshd |
| 7 | # |
| 8 | # and symbolic its link |
| 9 | # |
| 10 | # /sbin/rcsshd |
| 11 | # |
| 12 | |
| 13 | . /etc/rc.config |
| 14 | |
| 15 | # Determine the base and follow a runlevel link name. |
| 16 | base=${0##*/} |
| 17 | link=${base#*[SK][0-9][0-9]} |
| 18 | |
| 19 | # Force execution if not called by a runlevel directory. |
| 20 | test $link = $base && START_SSHD=yes |
| 21 | test "$START_SSHD" = yes || exit 0 |
| 22 | |
| 23 | # The echo return value for success (defined in /etc/rc.config). |
| 24 | return=$rc_done |
| 25 | case "$1" in |
| 26 | start) |
| 27 | echo -n "Starting service sshd" |
| 28 | ## Start daemon with startproc(8). If this fails |
| 29 | ## the echo return value is set appropriate. |
| 30 | |
| 31 | startproc /usr/sbin/sshd || return=$rc_failed |
| 32 | |
| 33 | echo -e "$return" |
| 34 | ;; |
| 35 | stop) |
| 36 | echo -n "Stopping service sshd" |
| 37 | ## Stop daemon with killproc(8) and if this fails |
| 38 | ## set echo the echo return value. |
| 39 | |
| 40 | killproc -TERM /usr/sbin/sshd || return=$rc_failed |
| 41 | |
| 42 | echo -e "$return" |
| 43 | ;; |
| 44 | restart) |
| 45 | ## If first returns OK call the second, if first or |
| 46 | ## second command fails, set echo return value. |
| 47 | $0 stop && $0 start || return=$rc_failed |
| 48 | ;; |
| 49 | reload) |
| 50 | ## Choose ONE of the following two cases: |
| 51 | |
| 52 | ## First possibility: A few services accepts a signal |
| 53 | ## to reread the (changed) configuration. |
| 54 | |
| 55 | echo -n "Reload service sshd" |
| 56 | killproc -HUP /usr/sbin/sshd || return=$rc_failed |
| 57 | echo -e "$return" |
| 58 | ;; |
| 59 | status) |
| 60 | echo -n "Checking for service sshd" |
| 61 | ## Check status with checkproc(8), if process is running |
| 62 | ## checkproc will return with exit status 0. |
| 63 | |
| 64 | checkproc /usr/sbin/sshd && echo OK || echo No process |
| 65 | ;; |
| 66 | probe) |
| 67 | ## Optional: Probe for the necessity of a reload, |
| 68 | ## give out the argument which is required for a reload. |
| 69 | |
| 70 | test /etc/ssh/sshd_config -nt /var/run/sshd.pid && echo reload |
| 71 | ;; |
| 72 | *) |
| 73 | echo "Usage: $0 {start|stop|status|restart|reload[|probe]}" |
| 74 | exit 1 |
| 75 | ;; |
| 76 | esac |
| 77 | |
| 78 | # Inform the caller not only verbosely and set an exit status. |
| 79 | test "$return" = "$rc_done" || exit 1 |
| 80 | exit 0 |