From 997ef7c3b9d48c62061fa194a75e5a5cb9c2d2d0 Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Wed, 7 Sep 2011 23:10:42 +0200 Subject: [PATCH] openssh: start init scripts on RUNLEVEL=boot Signed-off-by: Stephan Raue --- packages/network/openssh/init.d/51_sshd | 84 +++++++++++++------------ 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/packages/network/openssh/init.d/51_sshd b/packages/network/openssh/init.d/51_sshd index f97a02e92e..dcfbe2449b 100644 --- a/packages/network/openssh/init.d/51_sshd +++ b/packages/network/openssh/init.d/51_sshd @@ -22,55 +22,61 @@ # # runlevels: openelec, textmode -( - RSA1_KEY="/storage/.cache/ssh/ssh_host_key" - RSA2_KEY="/storage/.cache/ssh/ssh_host_rsa_key" - DSA2_KEY="/storage/.cache/ssh/ssh_host_dsa_key" + RSA1_KEY="/storage/.cache/ssh/ssh_host_key" + RSA2_KEY="/storage/.cache/ssh/ssh_host_rsa_key" + DSA2_KEY="/storage/.cache/ssh/ssh_host_dsa_key" - KEYGEN="/usr/bin/ssh-keygen" - SSHD="/usr/sbin/sshd" + KEYGEN="/usr/bin/ssh-keygen" + SSHD="/usr/sbin/sshd" - # Check for the SSH1 RSA key - if [ ! -f $RSA1_KEY ] ; then - progress "SSH: generating SSH1 RSA key" +case $RUNLEVEL in + boot) + ( + # Check for the SSH1 RSA key + if [ ! -f $RSA1_KEY ] ; then + progress "SSH: generating SSH1 RSA key" - mkdir -p /storage/.cache/ssh - $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null - chmod 600 $RSA1_KEY - fi + mkdir -p /storage/.cache/ssh + $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null + chmod 600 $RSA1_KEY + fi - # Check for the SSH2 RSA key - if [ ! -f $RSA2_KEY ] ; then - progress "SSH: generating SSH2 RSA key" + # Check for the SSH2 RSA key + if [ ! -f $RSA2_KEY ] ; then + progress "SSH: generating SSH2 RSA key" - mkdir -p /storage/.cache/ssh - $KEYGEN -q -t rsa -f $RSA2_KEY -C '' -N '' >&/dev/null - chmod 600 $RSA2_KEY - fi + mkdir -p /storage/.cache/ssh + $KEYGEN -q -t rsa -f $RSA2_KEY -C '' -N '' >&/dev/null + chmod 600 $RSA2_KEY + fi - # Check for the SSH2 DSA key - if [ ! -f $DSA2_KEY ] ; then - progress "SSH: generating SSH2 DSA key" + # Check for the SSH2 DSA key + if [ ! -f $DSA2_KEY ] ; then + progress "SSH: generating SSH2 DSA key" - mkdir -p /storage/.cache/ssh - $KEYGEN -q -t dsa -f $DSA2_KEY -C '' -N '' >&/dev/null - chmod 600 $DSA2_KEY - fi + mkdir -p /storage/.cache/ssh + $KEYGEN -q -t dsa -f $DSA2_KEY -C '' -N '' >&/dev/null + chmod 600 $DSA2_KEY + fi - # Check for predifined known hosts file - if [ -f /etc/ssh/known_hosts -a ! -f $HOME/.ssh/known_hosts ] ; then - progress "SSH: setup predifined known hosts" + # Check for predifined known hosts file + if [ -f /etc/ssh/known_hosts -a ! -f $HOME/.ssh/known_hosts ] ; then + progress "SSH: setup predifined known hosts" - mkdir -p /$HOME/.ssh - cp /etc/ssh/known_hosts $HOME/.ssh - fi + mkdir -p /$HOME/.ssh + cp /etc/ssh/known_hosts $HOME/.ssh + fi - progress "Starting SSH Server" + progress "Starting SSH Server" - wait_for_network + wait_for_network - mkdir -p /var/empty - chmod -R 600 /var/empty - $SSHD + mkdir -p /var/empty + chmod -R 600 /var/empty + $SSHD + )& + ;; -)& + poweroff|reboot) + ;; +esac