S50dropbear 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. #
  3. # Starts dropbear sshd.
  4. #
  5. # Make sure the dropbearkey progam exists
  6. [ -f /usr/bin/dropbearkey ] || exit 0
  7. start() {
  8. echo -n "Starting dropbear sshd: "
  9. # Make sure dropbear directory exists
  10. if [ ! -d /etc/dropbear ] ; then
  11. mkdir -p /etc/dropbear
  12. fi
  13. # Check for the Dropbear RSA key
  14. if [ ! -f /etc/dropbear/dropbear_rsa_host_key ] ; then
  15. echo -n "generating rsa key... "
  16. /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key > /dev/null 2>&1
  17. fi
  18. # Check for the Dropbear DSS key
  19. if [ ! -f /etc/dropbear/dropbear_dss_host_key ] ; then
  20. echo -n "generating dsa key... "
  21. /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key > /dev/null 2>&1
  22. fi
  23. umask 077
  24. start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear
  25. echo "OK"
  26. }
  27. stop() {
  28. echo -n "Stopping dropbear sshd: "
  29. start-stop-daemon -K -q -p /var/run/dropbear.pid
  30. echo "OK"
  31. }
  32. restart() {
  33. stop
  34. start
  35. }
  36. case "$1" in
  37. start)
  38. start
  39. ;;
  40. stop)
  41. stop
  42. ;;
  43. restart|reload)
  44. restart
  45. ;;
  46. *)
  47. echo $"Usage: $0 {start|stop|restart}"
  48. exit 1
  49. esac
  50. exit $?