From 06a338593c752686cd41db37648a53b593e9f55f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 12 Jun 2007 18:05:07 +0000 Subject: * Use LSB functions in init scripts, and add an LSB-style header (thanks, Christian Perrier; closes: #389038). --- debian/changelog | 2 ++ debian/control | 2 +- debian/openssh-server.init | 63 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3a74c5d0c..babd4571d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -56,6 +56,8 @@ openssh (1:4.6p1-1) UNRELEASED; urgency=low http://www.sxw.org.uk/computing/patches/openssh-4.6p1-gsskex-20070312.patch; install ChangeLog.gssapi. * Build the .deb --with-ssl-engine (LP: #119295). + * Use LSB functions in init scripts, and add an LSB-style header (thanks, + Christian Perrier; closes: #389038). -- Colin Watson Tue, 12 Jun 2007 14:31:01 +0100 diff --git a/debian/control b/debian/control index b266750ad..10ca6ad8f 100644 --- a/debian/control +++ b/debian/control @@ -36,7 +36,7 @@ Description: secure shell client, an rlogin/rsh/rcp replacement Package: openssh-server Priority: optional Architecture: any -Depends: ${shlibs:Depends}, ${debconf-depends}, ${pam-depends}, libpam-modules (>= 0.72-9), adduser (>= 3.9), dpkg (>= 1.9.0), openssh-client (= ${Source-Version}) +Depends: ${shlibs:Depends}, ${debconf-depends}, ${pam-depends}, libpam-modules (>= 0.72-9), adduser (>= 3.9), dpkg (>= 1.9.0), openssh-client (= ${Source-Version}), lsb-base (>= 3.0-6) Conflicts: ssh (<< 1:3.8.1p1-9), ssh-nonfree (<<2), ssh-socks, ssh2, sftp, rsh-client (<<0.16.1-1), ssh-krb5 (<< 1:4.3p2-7) Replaces: ssh, openssh-client (<< 1:3.8.1p1-11), ssh-krb5 Suggests: ssh-askpass, xbase-clients, rssh, molly-guard diff --git a/debian/openssh-server.init b/debian/openssh-server.init index f93150390..6fd04bb74 100644 --- a/debian/openssh-server.init +++ b/debian/openssh-server.init @@ -1,4 +1,13 @@ #! /bin/sh + +### BEGIN INIT INFO +# Provides: sshd +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +### END INIT INFO + set -e # /etc/init.d/ssh: start and stop the OpenBSD "secure shell(tm)" daemon @@ -10,10 +19,22 @@ if test -f /etc/default/ssh; then . /etc/default/ssh fi +. /lib/lsb/init-functions + +# Are we running from init? +run_by_init() { + ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ] +} + check_for_no_start() { # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists if [ -e /etc/ssh/sshd_not_to_be_run ]; then - echo "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)" + if [ "$1" = log_end_msg ]; then + log_end_msg 0 + fi + if ! run_by_init; then + log_action_msg "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)" + fi exit 0 fi } @@ -37,37 +58,49 @@ export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" case "$1" in start) check_for_no_start + log_daemon_msg "Starting OpenBSD Secure Shell server" "sshd" check_privsep_dir - echo -n "Starting OpenBSD Secure Shell server: sshd" - start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS - echo "." + if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi ;; stop) - echo -n "Stopping OpenBSD Secure Shell server: sshd" - start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid - echo "." + log_daemon_msg "Stopping OpenBSD Secure Shell server" "sshd" + if start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid; then + log_end_msg 0 + else + log_end_msg 1 + fi ;; reload|force-reload) check_for_no_start check_config - echo -n "Reloading OpenBSD Secure Shell server's configuration" - start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd - echo "." + log_daemon_msg "Reloading OpenBSD Secure Shell server's configuration" "sshd" + if start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd; then + log_end_msg 0 + else + log_end_msg 1 + fi ;; restart) check_privsep_dir check_config - echo -n "Restarting OpenBSD Secure Shell server: sshd" + log_daemon_msg "Restarting OpenBSD Secure Shell server" "sshd" start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/sshd.pid - check_for_no_start - start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS - echo "." + check_for_no_start log_end_msg + if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi ;; *) - echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}" + log_action_msg "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}" exit 1 esac -- cgit v1.2.3