1 |
vapier 11/01/24 02:55:47 |
2 |
|
3 |
Added: sshd.rc6.2 |
4 |
Log: |
5 |
Version bump. |
6 |
|
7 |
(Portage version: 2.2.0_alpha19/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 net-misc/openssh/files/sshd.rc6.2 |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openssh/files/sshd.rc6.2?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/openssh/files/sshd.rc6.2?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: sshd.rc6.2 |
16 |
=================================================================== |
17 |
#!/sbin/runscript |
18 |
# Copyright 1999-2011 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.2,v 1.1 2011/01/24 02:55:47 vapier Exp $ |
21 |
|
22 |
opts="${opts} reload checkconfig gen_keys" |
23 |
|
24 |
depend() { |
25 |
use logger dns |
26 |
need net |
27 |
} |
28 |
|
29 |
SSHD_CONFDIR=${SSHD_CONFDIR:-/etc/ssh} |
30 |
SSHD_PIDFILE=${SSHD_PIDFILE:-/var/run/${SVCNAME}.pid} |
31 |
SSHD_BINARY=${SSHD_BINARY:-/usr/sbin/sshd} |
32 |
|
33 |
checkconfig() { |
34 |
if [ ! -d /var/empty ] ; then |
35 |
mkdir -p /var/empty || return 1 |
36 |
fi |
37 |
|
38 |
if [ ! -e "${SSHD_CONFDIR}"/sshd_config ] ; then |
39 |
eerror "You need an ${SSHD_CONFDIR}/sshd_config file to run sshd" |
40 |
eerror "There is a sample file in /usr/share/doc/openssh" |
41 |
return 1 |
42 |
fi |
43 |
|
44 |
gen_keys || return 1 |
45 |
|
46 |
"${SSHD_BINARY}" -t ${myopts} || return 1 |
47 |
} |
48 |
|
49 |
gen_key() { |
50 |
local type=$1 key ks |
51 |
[ $# -eq 1 ] && ks="${type}_" |
52 |
key="${SSHD_CONFDIR}/ssh_host_${ks}key" |
53 |
if [ ! -e "${key}" ] ; then |
54 |
ebegin "Generating ${type} host key" |
55 |
ssh-keygen -t ${type} -f "${key}" -N '' |
56 |
eend $? || return $? |
57 |
fi |
58 |
} |
59 |
|
60 |
gen_keys() { |
61 |
if egrep -q '^[[:space:]]*Protocol[[:space:]]+.*1' "${SSHD_CONFDIR}"/sshd_config ; then |
62 |
gen_key rsa1 "" || return 1 |
63 |
fi |
64 |
gen_key dsa && gen_key rsa && gen_key ecdsa |
65 |
return $? |
66 |
} |
67 |
|
68 |
start() { |
69 |
local myopts="" |
70 |
[ "${SSHD_PIDFILE}" != "/var/run/sshd.pid" ] \ |
71 |
&& myopts="${myopts} -o PidFile=${SSHD_PIDFILE}" |
72 |
[ "${SSHD_CONFDIR}" != "/etc/ssh" ] \ |
73 |
&& myopts="${myopts} -f ${SSHD_CONFDIR}/sshd_config" |
74 |
|
75 |
checkconfig || return 1 |
76 |
ebegin "Starting ${SVCNAME}" |
77 |
start-stop-daemon --start --exec "${SSHD_BINARY}" \ |
78 |
--pidfile "${SSHD_PIDFILE}" \ |
79 |
-- ${myopts} ${SSHD_OPTS} |
80 |
eend $? |
81 |
} |
82 |
|
83 |
stop() { |
84 |
if [ "${RC_CMD}" = "restart" ] ; then |
85 |
checkconfig || return 1 |
86 |
fi |
87 |
|
88 |
ebegin "Stopping ${SVCNAME}" |
89 |
start-stop-daemon --stop --exec "${SSHD_BINARY}" \ |
90 |
--pidfile "${SSHD_PIDFILE}" --quiet |
91 |
eend $? |
92 |
} |
93 |
|
94 |
reload() { |
95 |
checkconfig || return 1 |
96 |
ebegin "Reloading ${SVCNAME}" |
97 |
start-stop-daemon --stop --signal HUP --oknodo \ |
98 |
--exec "${SSHD_BINARY}" --pidfile "${SSHD_PIDFILE}" |
99 |
eend $? |
100 |
} |