rc.main 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh -
  2. #
  3. # sshd/rc.main
  4. #
  5. # The OpenSSH SSH daemon.
  6. #
  7. # Redirects the standard error to the standard output
  8. exec 2>&1
  9. TARGET="$1"
  10. SVNAME="${2:-sshd}"
  11. make_keys()
  12. {
  13. if test ! -f /etc/ssh/ssh_host_key || test ! -s /etc/ssh/ssh_host_key
  14. then
  15. echo "*** ${SVNAME}: Generating /etc/ssh/ssh_host_key ..."
  16. /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ''
  17. fi
  18. if test ! -f /etc/ssh/ssh_host_dsa_key || test ! -s /etc/ssh/ssh_host_dsa_key
  19. then
  20. echo "*** ${SVNAME}: Generating /etc/ssh/ssh_host_dsa_key ..."
  21. /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
  22. fi
  23. if test ! -f /etc/ssh/ssh_host_rsa_key || test ! -s /etc/ssh/ssh_host_rsa_key
  24. then
  25. echo "*** ${SVNAME}: Generating /etc/ssh/ssh_host_rsa_key ..."
  26. /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
  27. fi
  28. }
  29. start()
  30. {
  31. echo "*** ${SVNAME}: Starting sshd ..."
  32. make_keys
  33. # sshd options required for perp service:
  34. # -D no detach, run in foreground
  35. # -e log to stderr (for tinylog) instead of syslog
  36. #
  37. exec /usr/sbin/sshd -D -e -f /etc/ssh/sshd_config
  38. }
  39. reset()
  40. {
  41. case $3 in
  42. exit)
  43. echo "*** ${SVNAME}: Exited status $4"
  44. ;;
  45. signal)
  46. echo "*** ${SVNAME}: Killed on signal $5"
  47. ;;
  48. *)
  49. echo "*** ${SVNAME}: Stopped (${3})"
  50. ;;
  51. esac
  52. }
  53. # Branch to target
  54. eval ${TARGET} "$@"