sshd.rc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/sbin/sh
  2. #
  3. # sshd.rc: SSH daemon start-up and shutdown script
  4. #
  5. # Allowed exit values:
  6. # 0 = success; causes "OK" to show up in checklist.
  7. # 1 = failure; causes "FAIL" to show up in checklist.
  8. # 2 = skip; causes "N/A" to show up in the checklist.
  9. # Use this value if execution of this script is overridden
  10. # by the use of a control variable, or if this script is not
  11. # appropriate to execute for some other reason.
  12. # 3 = reboot; causes the system to be rebooted after execution.
  13. # Input and output:
  14. # stdin is redirected from /dev/null
  15. #
  16. # stdout and stderr are redirected to the /etc/rc.log file
  17. # during checklist mode, or to the console in raw mode.
  18. PATH=/usr/sbin:/usr/bin:/sbin
  19. export PATH
  20. WHAT='OpenSSH'
  21. WHAT_PATH=/opt/openssh/sbin/sshd
  22. WHAT_PID=/var/run/sshd.pid
  23. WHAT_CONFIG=/etc/rc.config.d/sshd
  24. # NOTE: If your script executes in run state 0 or state 1, then /usr might
  25. # not be available. Do not attempt to access commands or files in
  26. # /usr unless your script executes in run state 2 or greater. Other
  27. # file systems typically not mounted until run state 2 include /var
  28. # and /opt.
  29. rval=0
  30. # Check the exit value of a command run by this script. If non-zero, the
  31. # exit code is echoed to the log file and the return value of this script
  32. # is set to indicate failure.
  33. set_return() {
  34. x=$?
  35. if [ $x -ne 0 ]; then
  36. echo "EXIT CODE: $x"
  37. rval=1 # script FAILed
  38. fi
  39. }
  40. case $1 in
  41. 'start_msg')
  42. echo "Starting $WHAT"
  43. ;;
  44. 'stop_msg')
  45. echo "Stopping $WHAT"
  46. ;;
  47. 'start')
  48. if [ -f $WHAT_CONFIG ] ; then
  49. . $WHAT_CONFIG
  50. else
  51. echo "ERROR: $WHAT_CONFIG defaults file MISSING"
  52. fi
  53. if [ "$SSHD_START" -eq 1 -a -x "$WHAT_PATH" ]; then
  54. $WHAT_PATH $SSHD_ARGS && echo "$WHAT started"
  55. set_return
  56. else
  57. rval=2
  58. fi
  59. ;;
  60. 'stop')
  61. if kill `cat $WHAT_PID`; then
  62. echo "$WHAT stopped"
  63. else
  64. rval=1
  65. echo "Unable to stop $WHAT"
  66. fi
  67. set_return
  68. ;;
  69. *)
  70. echo "usage: $0 {start|stop|start_msg|stop_msg}"
  71. rval=1
  72. ;;
  73. esac
  74. exit $rval