S50dropbear 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. echo -n "Starting dropbear sshd: "
  10. umask 077
  11. # If /etc/dropbear is not a directory, and
  12. # - the filesystem is RO (i.e. we can not rm the symlink),
  13. # create the directory pointed to by the symlink.
  14. # - the filesystem is RW (i.e. we can rm the symlink),
  15. # replace the symlink with an actual directory
  16. if ! [ -d /etc/dropbear ]; then
  17. if rm -f /etc/dropbear; then
  18. mkdir -p /etc/dropbear
  19. else
  20. mkdir -p $(readlink /etc/dropbear)
  21. fi
  22. fi
  23. start-stop-daemon -S -q -p /var/run/dropbear.pid \
  24. --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
  25. [ $? = 0 ] && echo "OK" || echo "FAIL"
  26. }
  27. stop() {
  28. echo -n "Stopping dropbear sshd: "
  29. start-stop-daemon -K -q -p /var/run/dropbear.pid
  30. [ $? = 0 ] && echo "OK" || echo "FAIL"
  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 $?