Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-misc/openssh/files: sshd.rc6.4
Date: Wed, 28 Nov 2012 00:32:34
Message-Id: 20121128003224.C562F20C65@flycatcher.gentoo.org
1 robbat2 12/11/28 00:32:24
2
3 Added: sshd.rc6.4
4 Log:
5 Cleanup of sshd init.d in preparation for bug #410541. local keyword is not POSIX sh.
6
7 (Portage version: 2.2.0_alpha142/cvs/Linux x86_64, unsigned Manifest commit)
8
9 Revision Changes Path
10 1.1 net-misc/openssh/files/sshd.rc6.4
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openssh/files/sshd.rc6.4?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openssh/files/sshd.rc6.4?rev=1.1&content-type=text/plain
14
15 Index: sshd.rc6.4
16 ===================================================================
17 #!/sbin/runscript
18 # Copyright 1999-2012 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20 # $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/files/sshd.rc6.4,v 1.1 2012/11/28 00:32:24 robbat2 Exp $
21
22 extra_commands="checkconfig gen_keys"
23 extra_started_commands="reload"
24
25 depend() {
26 use logger dns
27 need net
28 }
29
30 SSHD_CONFDIR=${SSHD_CONFDIR:-/etc/ssh}
31 SSHD_PIDFILE=${SSHD_PIDFILE:-/var/run/${SVCNAME}.pid}
32 SSHD_BINARY=${SSHD_BINARY:-/usr/sbin/sshd}
33
34 checkconfig() {
35 if [ ! -d /var/empty ] ; then
36 mkdir -p /var/empty || return 1
37 fi
38
39 if [ ! -e "${SSHD_CONFDIR}"/sshd_config ] ; then
40 eerror "You need an ${SSHD_CONFDIR}/sshd_config file to run sshd"
41 eerror "There is a sample file in /usr/share/doc/openssh"
42 return 1
43 fi
44
45 gen_keys || return 1
46
47 [ "${SSHD_PIDFILE}" != "/var/run/sshd.pid" ] \
48 && SSHD_OPTS="${SSHD_OPTS} -o PidFile=${SSHD_PIDFILE}"
49 [ "${SSHD_CONFDIR}" != "/etc/ssh" ] \
50 && SSHD_OPTS="${SSHD_OPTS} -f ${SSHD_CONFDIR}/sshd_config"
51
52 "${SSHD_BINARY}" -t ${SSHD_OPTS} || return 1
53 }
54
55 gen_key() {
56 keytype=$1
57 [ $# -eq 1 ] && ks="${keytype}_"
58 key="${SSHD_CONFDIR}/ssh_host_${ks}key"
59 if [ ! -e "${key}" ] ; then
60 ebegin "Generating ${keytype} host key"
61 ssh-keygen -t ${keytype} -f "${key}" -N ''
62 eend $? || return $?
63 fi
64 }
65
66 gen_keys() {
67 if egrep -q '^[[:space:]]*Protocol[[:space:]]+.*1' "${SSHD_CONFDIR}"/sshd_config ; then
68 gen_key rsa1 "" || return 1
69 fi
70 gen_key dsa && gen_key rsa && gen_key ecdsa
71 return $?
72 }
73
74 start() {
75 checkconfig || return 1
76
77 ebegin "Starting ${SVCNAME}"
78 start-stop-daemon --start --exec "${SSHD_BINARY}" \
79 --pidfile "${SSHD_PIDFILE}" \
80 -- ${SSHD_OPTS}
81 eend $?
82 }
83
84 stop() {
85 if [ "${RC_CMD}" = "restart" ] ; then
86 checkconfig || return 1
87 fi
88
89 ebegin "Stopping ${SVCNAME}"
90 start-stop-daemon --stop --exec "${SSHD_BINARY}" \
91 --pidfile "${SSHD_PIDFILE}" --quiet
92 eend $?
93 }
94
95 reload() {
96 checkconfig || return 1
97 ebegin "Reloading ${SVCNAME}"
98 start-stop-daemon --signal HUP \
99 --exec "${SSHD_BINARY}" --pidfile "${SSHD_PIDFILE}"
100 eend $?
101 }