nscd.init 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. #
  3. # nscd: Starts the Name Switch Cache Daemon
  4. #
  5. # chkconfig: - 30 74
  6. # description: This is a daemon which handles passwd and group lookups \
  7. # for running programs and cache the results for the next \
  8. # query. You should start this daemon if you use \
  9. # slow naming services like NIS, NIS+, LDAP, or hesiod.
  10. # processname: /usr/sbin/nscd
  11. # config: /etc/nscd.conf
  12. #
  13. ### BEGIN INIT INFO
  14. # Provides: nscd
  15. # Required-Start: $syslog
  16. # Default-Stop: 0 1 6
  17. # Short-Description: Starts the Name Switch Cache Daemon
  18. # Description: This is a daemon which handles passwd and group lookups \
  19. # for running programs and cache the results for the next \
  20. # query. You should start this daemon if you use \
  21. # slow naming services like NIS, NIS+, LDAP, or hesiod.
  22. ### END INIT INFO
  23. # Sanity checks.
  24. [ -f /etc/nscd.conf ] || exit 0
  25. [ -x /usr/sbin/nscd ] || exit 0
  26. # Source function library.
  27. . /etc/init.d/functions
  28. # nscd does not run on any kernel lower than 2.2.0 because of threading
  29. # problems, so we require that in first place.
  30. case $(uname -r) in
  31. 2.[2-9].*)
  32. # this is okay
  33. ;;
  34. [3-9]*)
  35. # these are of course also okay
  36. ;;
  37. *)
  38. #this is not
  39. exit 1
  40. ;;
  41. esac
  42. RETVAL=0
  43. prog=nscd
  44. start () {
  45. [ -d /var/run/nscd ] || mkdir /var/run/nscd
  46. [ -d /var/db/nscd ] || mkdir /var/db/nscd
  47. echo -n $"Starting $prog: "
  48. daemon /usr/sbin/nscd
  49. RETVAL=$?
  50. echo
  51. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
  52. return $RETVAL
  53. }
  54. stop () {
  55. echo -n $"Stopping $prog: "
  56. /usr/sbin/nscd -K
  57. RETVAL=$?
  58. if [ $RETVAL -eq 0 ]; then
  59. rm -f /var/lock/subsys/nscd
  60. # nscd won't be able to remove these if it is running as
  61. # a non-privileged user
  62. rm -f /var/run/nscd/nscd.pid
  63. rm -f /var/run/nscd/socket
  64. success $"$prog shutdown"
  65. else
  66. failure $"$prog shutdown"
  67. fi
  68. echo
  69. return $RETVAL
  70. }
  71. restart() {
  72. stop
  73. start
  74. }
  75. # See how we were called.
  76. case "$1" in
  77. start)
  78. start
  79. RETVAL=$?
  80. ;;
  81. stop)
  82. stop
  83. RETVAL=$?
  84. ;;
  85. status)
  86. status nscd
  87. RETVAL=$?
  88. ;;
  89. restart)
  90. restart
  91. RETVAL=$?
  92. ;;
  93. try-restart | condrestart)
  94. [ -e /var/lock/subsys/nscd ] && restart
  95. RETVAL=$?
  96. ;;
  97. force-reload | reload)
  98. echo -n $"Reloading $prog: "
  99. killproc /usr/sbin/nscd -HUP
  100. RETVAL=$?
  101. echo
  102. ;;
  103. *)
  104. echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
  105. RETVAL=1
  106. ;;
  107. esac
  108. exit $RETVAL