diff options
Diffstat (limited to 'contrib/caldera/sshd.init')
-rwxr-xr-x | contrib/caldera/sshd.init | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/contrib/caldera/sshd.init b/contrib/caldera/sshd.init new file mode 100755 index 000000000..17643391b --- /dev/null +++ b/contrib/caldera/sshd.init | |||
@@ -0,0 +1,99 @@ | |||
1 | #! /bin/sh | ||
2 | # | ||
3 | # Generic network daemon RC script. If installed as /etc/rc.d/init.d/foobar, | ||
4 | # it source /etc/sysconfig/daemons/foobar and looks at the | ||
5 | # variable definitions (Bourne shell syntax). Variables marked with an | ||
6 | # asterisk are required. | ||
7 | # | ||
8 | # * IDENT=sshd | ||
9 | # DESCRIPTIVE="@OPENSSH_VERSION@" | ||
10 | # * DAEMON=/usr/sbin/sshd | ||
11 | # DAEMON_ARGS="-p some_other_port" | ||
12 | # ONBOOT=yes | ||
13 | # | ||
14 | |||
15 | # Source networking configuration. | ||
16 | . /etc/sysconfig/network | ||
17 | |||
18 | # Check that networking is up. | ||
19 | [ ${NETWORKING} = "no" ] && exit 0 | ||
20 | |||
21 | # Source function library, check sysconfig/daemon file and source it. | ||
22 | . /etc/rc.d/init.d/functions | ||
23 | |||
24 | [ -x $DAEMON ] || exit 0 | ||
25 | |||
26 | # Some functions to make the below more readable | ||
27 | KEYGEN=/usr/bin/ssh-keygen | ||
28 | RSA1_KEY=/etc/ssh/ssh_host_key | ||
29 | RSA_KEY=/etc/ssh/ssh_host_rsa_key | ||
30 | DSA_KEY=/etc/ssh/ssh_host_dsa_key | ||
31 | PID_FILE=/var/run/sshd.pid | ||
32 | do_rsa1_keygen() { | ||
33 | if ! test -f $RSA1_KEY ; then | ||
34 | echo -n "Generating SSH1 RSA host key: " | ||
35 | if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then | ||
36 | echo "RSA1 key generation success" | ||
37 | else | ||
38 | echo "RSA1 key generation failure" | ||
39 | exit 1 | ||
40 | fi | ||
41 | fi | ||
42 | } | ||
43 | do_rsa_keygen() { | ||
44 | if ! test -f $RSA_KEY ; then | ||
45 | echo -n "Generating SSH2 RSA host key: " | ||
46 | if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then | ||
47 | echo "RSA key generation success" | ||
48 | else | ||
49 | echo "RSA key generation failure" | ||
50 | exit 1 | ||
51 | fi | ||
52 | fi | ||
53 | } | ||
54 | do_dsa_keygen() { | ||
55 | if ! test -f $DSA_KEY ; then | ||
56 | echo -n "Generating SSH2 DSA host key: " | ||
57 | if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then | ||
58 | echo "DSA key generation success" | ||
59 | else | ||
60 | echo "DSA key generation failure" | ||
61 | exit 1 | ||
62 | fi | ||
63 | fi | ||
64 | } | ||
65 | |||
66 | # See how we were called. | ||
67 | case "$1" in | ||
68 | start) | ||
69 | # Create keys if necessary | ||
70 | do_rsa1_keygen | ||
71 | do_rsa_keygen | ||
72 | do_dsa_keygen | ||
73 | |||
74 | # Start daemons. | ||
75 | [ ! -e $LOCK ] || exit 1 | ||
76 | echo -n "Starting $SUBSYS services: " | ||
77 | start-stop-daemon -S -n $IDENT -x $DAEMON -- $DAEMON_ARGS | ||
78 | sleep 1 | ||
79 | echo . | ||
80 | touch $LOCK | ||
81 | ;; | ||
82 | stop) | ||
83 | # Stop daemons. | ||
84 | [ -e $LOCK ] || exit 0 | ||
85 | echo -n "Stopping $SUBSYS services: " | ||
86 | start-stop-daemon -K -n $IDENT -x $DAEMON | ||
87 | echo | ||
88 | rm -f $LOCK | ||
89 | ;; | ||
90 | restart) | ||
91 | $0 stop | ||
92 | $0 start | ||
93 | ;; | ||
94 | *) | ||
95 | echo "Usage: $SUBSYS {start|stop|restart}" | ||
96 | exit 1 | ||
97 | esac | ||
98 | |||
99 | exit 0 | ||