logo

overlay

My (experimental) gentoo overlay

dropbear.init.d (731B)


      1 #!/sbin/openrc-run
      2 # Copyright 1999-2014 Gentoo Foundation
      3 # Distributed under the terms of the GNU General Public License v2
      4 
      5 depend() {
      6 	use logger dns
      7 	need net
      8 }
      9 
     10 check_config() {
     11 	mkdir -p /etc/dropbear
     12 
     13 	local t k
     14 	for t in dss rsa ecdsa; do
     15 		k="/etc/dropbear/dropbear_${t}_host_key"
     16 		if [ ! -e ${k} ] ; then
     17 			# See if support is enabled for this key type.
     18 			if dropbearkey -h 2>&1 | grep -q "	${t}$" ; then
     19 				einfo "Generating ${k} ..."
     20 				dropbearkey -t ${t} -f ${k} >/dev/null
     21 			fi
     22 		fi &
     23 	done
     24 	wait
     25 }
     26 
     27 start() {
     28 	check_config || return 1
     29 	ebegin "Starting dropbear"
     30 	dropbear ${DROPBEAR_OPTS}
     31 	eend $?
     32 }
     33 
     34 stop() {
     35 	ebegin "Stopping dropbear"
     36 	start-stop-daemon --stop --pidfile /var/run/dropbear.pid
     37 	eend $?
     38 }