S50dropbear 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. #
  3. # Starts dropbear sshd.
  4. #
  5. # Allow a few customizations from a config file
  6. test -r /etc/default/dropbear && . /etc/default/dropbear
  7. start() {
  8. DROPBEAR_ARGS="$DROPBEAR_ARGS -R"
  9. # If /etc/dropbear is a symlink to /var/run/dropbear, and
  10. # - the filesystem is RO (i.e. we can not rm the symlink),
  11. # create the directory pointed to by the symlink.
  12. # - the filesystem is RW (i.e. we can rm the symlink),
  13. # replace the symlink with an actual directory
  14. if [ -L /etc/dropbear \
  15. -a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]
  16. then
  17. if rm -f /etc/dropbear >/dev/null 2>&1; then
  18. mkdir -p /etc/dropbear
  19. else
  20. echo "No persistent location to store SSH host keys. New keys will be"
  21. echo "generated at each boot. Are you sure this is what you want to do?"
  22. mkdir -p "$(readlink /etc/dropbear)"
  23. fi
  24. fi
  25. printf "Starting dropbear sshd: "
  26. umask 077
  27. start-stop-daemon -S -q -p /var/run/dropbear.pid \
  28. --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
  29. [ $? = 0 ] && echo "OK" || echo "FAIL"
  30. }
  31. stop() {
  32. printf "Stopping dropbear sshd: "
  33. start-stop-daemon -K -q -p /var/run/dropbear.pid
  34. [ $? = 0 ] && echo "OK" || echo "FAIL"
  35. }
  36. restart() {
  37. stop
  38. start
  39. }
  40. case "$1" in
  41. start)
  42. start
  43. ;;
  44. stop)
  45. stop
  46. ;;
  47. restart|reload)
  48. restart
  49. ;;
  50. *)
  51. echo "Usage: $0 {start|stop|restart}"
  52. exit 1
  53. esac
  54. exit $?