dropbear.init 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: dropbear
  4. # Required-Start: $remote_fs $syslog
  5. # Required-Stop: $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Dropbear SSH server
  9. ### END INIT INFO
  10. #
  11. # Do not configure this file. Edit /etc/default/dropbear instead!
  12. #
  13. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  14. DAEMON=/usr/sbin/dropbear
  15. NAME=dropbear
  16. DESC="Dropbear SSH server"
  17. DROPBEAR_PORT=22
  18. DROPBEAR_EXTRA_ARGS=
  19. NO_START=0
  20. set -e
  21. cancel() { echo "$1" >&2; exit 0; };
  22. test ! -r /etc/default/dropbear || . /etc/default/dropbear
  23. test -x "$DAEMON" || cancel "$DAEMON does not exist or is not executable."
  24. test ! -x /usr/sbin/update-service || ! update-service --check dropbear ||
  25. cancel 'The dropbear service is controlled through runit, use the sv(8) program'
  26. test -z "$DROPBEAR_BANNER" || \
  27. DROPBEAR_EXTRA_ARGS="$DROPBEAR_EXTRA_ARGS -b $DROPBEAR_BANNER"
  28. test -n "$DROPBEAR_RSAKEY" || \
  29. DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key"
  30. test -n "$DROPBEAR_DSSKEY" || \
  31. DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key"
  32. test -n "$DROPBEAR_RECEIVE_WINDOW" || \
  33. DROPBEAR_RECEIVE_WINDOW="65536"
  34. case "$1" in
  35. start)
  36. test "$NO_START" = "0" || cancel 'NO_START is not set to zero.'
  37. echo -n "Starting $DESC: "
  38. start-stop-daemon --start --quiet --pidfile /var/run/"$NAME".pid \
  39. --exec "$DAEMON" -- -d "$DROPBEAR_DSSKEY" -r "$DROPBEAR_RSAKEY" \
  40. -p "$DROPBEAR_PORT" -W "$DROPBEAR_RECEIVE_WINDOW" $DROPBEAR_EXTRA_ARGS
  41. echo "$NAME."
  42. ;;
  43. stop)
  44. echo -n "Stopping $DESC: "
  45. start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/"$NAME".pid
  46. echo "$NAME."
  47. ;;
  48. restart|force-reload)
  49. test "$NO_START" = "0" || cancel 'NO_START is not set to zero.'
  50. echo -n "Restarting $DESC: "
  51. start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/"$NAME".pid
  52. sleep 1
  53. start-stop-daemon --start --quiet --pidfile /var/run/"$NAME".pid \
  54. --exec "$DAEMON" -- -d "$DROPBEAR_DSSKEY" -r "$DROPBEAR_RSAKEY" \
  55. -p "$DROPBEAR_PORT" -W "$DROPBEAR_RECEIVE_WINDOW" $DROPBEAR_EXTRA_ARGS
  56. echo "$NAME."
  57. ;;
  58. *)
  59. N=/etc/init.d/$NAME
  60. echo "Usage: $N {start|stop|restart|force-reload}" >&2
  61. exit 1
  62. ;;
  63. esac
  64. exit 0