dropbear.init 833 B

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