diff options
Diffstat (limited to 'projectroot/etc/rc.once.d/dropbear')
-rw-r--r-- | projectroot/etc/rc.once.d/dropbear | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/projectroot/etc/rc.once.d/dropbear b/projectroot/etc/rc.once.d/dropbear new file mode 100644 index 000000000..a126b26db --- /dev/null +++ b/projectroot/etc/rc.once.d/dropbear @@ -0,0 +1,33 @@ +#!/bin/sh + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +DROPBEAR_RSAKEY_DEFAULT="@KEYDIR@/dropbear_rsa_host_key" +DROPBEAR_DSSKEY_DEFAULT="@KEYDIR@/dropbear_dss_host_key" + +test -n "$DROPBEAR_RSAKEY" || \ + DROPBEAR_RSAKEY=$DROPBEAR_RSAKEY_DEFAULT +test -n "$DROPBEAR_DSSKEY" || \ + DROPBEAR_DSSKEY=$DROPBEAR_DSSKEY_DEFAULT + +gen_key() { + + key_type=$1 + key_file=$2 + + rm -f $key_file > /dev/null 2>&1 + + echo -n "generating $key_type key..." + dropbearkey -t $key_type -f $key_file > /dev/null 2>&1 + + if [ "$?" = "0" ]; then + echo "done" + else + echo "failed" + exit 1 + fi +} + +[ -e "$DROPBEAR_RSAKEY" ] || gen_key rsa "$DROPBEAR_RSAKEY" +[ -e "$DROPBEAR_DSSKEY" ] || gen_key dss "$DROPBEAR_DSSKEY" + |