egd.rc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/sbin/sh
  2. #
  3. # egd.rc: EGD 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. umask 022
  19. PATH=/usr/sbin:/usr/bin:/sbin
  20. export PATH
  21. WHAT='EGD (entropy gathering daemon)'
  22. WHAT_PATH=/opt/perl/bin/egd.pl
  23. WHAT_CONFIG=/etc/rc.config.d/egd
  24. WHAT_LOG=/etc/opt/egd/egd.log
  25. # NOTE: If your script executes in run state 0 or state 1, then /usr might
  26. # not be available. Do not attempt to access commands or files in
  27. # /usr unless your script executes in run state 2 or greater. Other
  28. # file systems typically not mounted until run state 2 include /var
  29. # and /opt.
  30. rval=0
  31. # Check the exit value of a command run by this script. If non-zero, the
  32. # exit code is echoed to the log file and the return value of this script
  33. # is set to indicate failure.
  34. set_return() {
  35. x=$?
  36. if [ $x -ne 0 ]; then
  37. echo "EXIT CODE: $x"
  38. rval=1 # script FAILed
  39. fi
  40. }
  41. case $1 in
  42. 'start_msg')
  43. echo "Starting $WHAT"
  44. ;;
  45. 'stop_msg')
  46. echo "Stopping $WHAT"
  47. ;;
  48. 'start')
  49. if [ -f $WHAT_CONFIG ] ; then
  50. . $WHAT_CONFIG
  51. else
  52. echo "ERROR: $WHAT_CONFIG defaults file MISSING"
  53. fi
  54. if [ "$EGD_START" -eq 1 -a -x $WHAT_PATH ]; then
  55. EGD_LOG=${EGD_LOG:-$WHAT_LOG}
  56. su egd -c "nohup $WHAT_PATH $EGD_ARGS >$EGD_LOG 2>&1" &&
  57. echo $WHAT started
  58. set_return
  59. else
  60. rval=2
  61. fi
  62. ;;
  63. 'stop')
  64. pid=`ps -fuegd | awk '$1 == "egd" { print $2 }'`
  65. if [ "X$pid" != "X" ]; then
  66. if kill "$pid"; then
  67. echo "$WHAT stopped"
  68. else
  69. rval=1
  70. echo "Unable to stop $WHAT"
  71. fi
  72. fi
  73. set_return
  74. ;;
  75. *)
  76. echo "usage: $0 {start|stop|start_msg|stop_msg}"
  77. rval=1
  78. ;;
  79. esac
  80. exit $rval