dropbear.postinst 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. set -e
  3. test "$1" = 'configure' || exit 0
  4. if test ! -e /etc/dropbear/dropbear_rsa_host_key; then
  5. if test -f /etc/ssh/ssh_host_rsa_key; then
  6. echo "Converting existing OpenSSH RSA host key to Dropbear format."
  7. /usr/lib/dropbear/dropbearconvert openssh dropbear \
  8. /etc/ssh/ssh_host_rsa_key /etc/dropbear/dropbear_rsa_host_key
  9. else
  10. echo "Generating Dropbear RSA key. Please wait."
  11. dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
  12. fi
  13. fi
  14. if test ! -e /etc/dropbear/dropbear_dss_host_key; then
  15. if test -f /etc/ssh/ssh_host_dsa_key; then
  16. echo "Converting existing OpenSSH RSA host key to Dropbear format."
  17. /usr/lib/dropbear/dropbearconvert openssh dropbear \
  18. /etc/ssh/ssh_host_dsa_key /etc/dropbear/dropbear_dss_host_key
  19. else
  20. echo "Generating Dropbear DSS key. Please wait."
  21. dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
  22. fi
  23. fi
  24. if test ! -s /etc/default/dropbear; then
  25. # check whether OpenSSH seems to be installed.
  26. if test -x /usr/sbin/sshd; then
  27. cat <<EOT
  28. OpenSSH appears to be installed. Setting /etc/default/dropbear so that
  29. Dropbear will not start by default. Edit this file to change this behaviour.
  30. EOT
  31. cat >>/etc/default/dropbear <<EOT
  32. # disabled because OpenSSH is installed
  33. # change to NO_START=0 to enable Dropbear
  34. NO_START=1
  35. EOT
  36. fi
  37. cat >>/etc/default/dropbear <<EOT
  38. # the TCP port that Dropbear listens on
  39. DROPBEAR_PORT=22
  40. # any additional arguments for Dropbear
  41. DROPBEAR_EXTRA_ARGS=
  42. # specify an optional banner file containing a message to be
  43. # sent to clients before they connect, such as "/etc/issue.net"
  44. DROPBEAR_BANNER=""
  45. # RSA hostkey file (default: /etc/dropbear/dropbear_rsa_host_key)
  46. #DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key"
  47. # DSS hostkey file (default: /etc/dropbear/dropbear_dss_host_key)
  48. #DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key"
  49. # Receive window size - this is a tradeoff between memory and
  50. # network performance
  51. DROPBEAR_RECEIVE_WINDOW=65536
  52. EOT
  53. fi
  54. if test -x /etc/init.d/dropbear; then
  55. update-rc.d dropbear defaults >/dev/null
  56. if test -x /usr/sbin/invoke-rc.d; then
  57. invoke-rc.d dropbear restart
  58. else
  59. /etc/init.d/dropbear restart
  60. fi
  61. fi
  62. if test -n "$2" && dpkg --compare-versions "$2" lt '0.50-4' &&
  63. update-service --check dropbear 2>/dev/null; then
  64. update-service --remove /etc/dropbear 2>/dev/null || :
  65. sleep 6
  66. rm -rf /var/run/dropbear /var/run/dropbear.log
  67. update-service --add /etc/dropbear || :
  68. fi