dropbear.init 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. #PKG dropbear
  3. #INIT 50
  4. . /etc/rc.conf
  5. case $1 in
  6. autostop) ;;
  7. autostart)
  8. test x"${dropbear:-NO}" = x"NO" && exit 0
  9. exec sh $0 start
  10. ;;
  11. start)
  12. if test ! -f /etc/dropbear/dropbear_rsa_host_key; then
  13. mkdir -p /etc/dropbear
  14. if test ! -x /usr/bin/dropbearkey; then
  15. echo "dropbear not starting: SSH private key missing"
  16. exit 0
  17. fi
  18. echo "dropbear: generating SSH private key (RSA)"
  19. /usr/bin/dropbearkey -f /etc/dropbear/dropbear_rsa_host_key \
  20. -t rsa ; rv=$?
  21. echo "dropbear: key generation exited with code $rv"
  22. test $rv = 0 || exit 1
  23. test -f /etc/dropbear/dropbear_rsa_host_key || exit 1
  24. fi
  25. if test ! -f /etc/dropbear/dropbear_dss_host_key; then
  26. # take it easy here, since above already catched the worst cases
  27. if test -x /usr/bin/dropbearkey; then
  28. echo "dropbear: generating SSH private key (DSS)"
  29. /usr/bin/dropbearkey -f /etc/dropbear/dropbear_dss_host_key -t dss
  30. echo "dropbear: key generation exited with code $?"
  31. fi
  32. fi
  33. /usr/sbin/dropbear $dropbear_flags
  34. ;;
  35. stop)
  36. kill $(pgrep -f /usr/sbin/dropbear)
  37. ;;
  38. restart)
  39. sh $0 stop
  40. sh $0 start
  41. ;;
  42. *)
  43. echo "Usage: $0 {start | stop | restart}"
  44. exit 1
  45. ;;
  46. esac
  47. exit $?