~ubuntu-branches/debian/sid/openssh/sid

« back to all changes in this revision

Viewing changes to debian/openssh-server.init

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2004-10-07 18:03:06 UTC
  • Revision ID: james.westby@ubuntu.com-20041007180306-0l8ii961txetbucx
Tags: 1:3.8.1p1-11ubuntu3
* Nathaniel McCallum:
  - debian/openssh-server.init: pretty initscript
  - debian/control: versioned depend on lsb-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
set -e
 
3
 
 
4
# /etc/init.d/ssh: start and stop the OpenBSD "secure shell(tm)" daemon
 
5
 
 
6
test -x /usr/sbin/sshd || exit 0
 
7
( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0
 
8
 
 
9
if test -f /etc/default/ssh; then
 
10
    . /etc/default/ssh
 
11
fi
 
12
 
 
13
. /lib/lsb/init-functions
 
14
 
 
15
check_for_no_start() {
 
16
    # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
 
17
    if [ -e /etc/ssh/sshd_not_to_be_run ]; then 
 
18
        log_end_msg 0
 
19
        log_warning_msg "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)"
 
20
        exit 0
 
21
    fi
 
22
}
 
23
 
 
24
check_privsep_dir() {
 
25
    # Create the PrivSep empty dir if necessary
 
26
    if [ ! -d /var/run/sshd ]; then
 
27
        mkdir /var/run/sshd
 
28
        chmod 0755 /var/run/sshd
 
29
    fi
 
30
}
 
31
 
 
32
check_config() {
 
33
    if [ ! -e /etc/ssh/sshd_not_to_be_run ]; then
 
34
        /usr/sbin/sshd -t || exit 1
 
35
    fi
 
36
}
 
37
 
 
38
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
 
39
 
 
40
case "$1" in
 
41
  start)
 
42
        log_begin_msg "Starting OpenBSD Secure Shell server..."
 
43
        check_for_no_start
 
44
        check_privsep_dir
 
45
        start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS || log_end_msg 1
 
46
        log_end_msg 0
 
47
        ;;
 
48
  stop)
 
49
        log_begin_msg "Stopping OpenBSD Secure Shell server..."
 
50
        start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid || log_end_msg 1
 
51
        log_end_msg 0
 
52
        ;;
 
53
 
 
54
  reload|force-reload)
 
55
        log_begin_msg "Reloading OpenBSD Secure Shell server's configuration"
 
56
        check_for_no_start
 
57
        check_config
 
58
        start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd || log_end_msg 1
 
59
        log_end_msg 0
 
60
        ;;
 
61
 
 
62
  restart)
 
63
        log_begin_msg "Restarting OpenBSD Secure Shell server..."
 
64
        check_config
 
65
        start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/sshd.pid
 
66
        check_for_no_start
 
67
        check_privsep_dir
 
68
        start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS || log_end_msg 1
 
69
        log_end_msg 0
 
70
        ;;
 
71
 
 
72
  *)
 
73
        log_success_msg "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
 
74
        exit 1
 
75
esac
 
76
 
 
77
exit 0