nscd.initd 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2005 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. depend() {
  5. use dns ldap net slapd
  6. }
  7. checkconfig() {
  8. if [ ! -d /var/run/nscd ] ; then
  9. mkdir -p /var/run/nscd
  10. chmod 755 /var/run/nscd
  11. fi
  12. if [ -z "${NSCD_PERMS_OK}" ] && [ "$(stat -c %a /var/run/nscd)" != "755" ] ; then
  13. echo ""
  14. ewarn "nscd run dir is not world readable, you should reset the perms:"
  15. ewarn "chmod 755 /var/run/nscd"
  16. ewarn "chmod a+rw /var/run/nscd/socket"
  17. echo ""
  18. ewarn "To disable this warning, set 'NSCD_PERMS_OK' in /etc/conf.d/nscd"
  19. echo ""
  20. fi
  21. }
  22. start() {
  23. checkconfig
  24. ebegin "Starting Name Service Cache Daemon"
  25. local secure=`while read curline ; do
  26. table=${curline%:*}
  27. entries=${curline##$table:}
  28. table=${table%%[^a-z]*}
  29. case $table in
  30. passwd*|group*|hosts)
  31. for entry in $entries ; do
  32. case $entry in
  33. nisplus*)
  34. /usr/sbin/nscd_nischeck $table || \
  35. /echo "-S $table,yes"
  36. ;;
  37. esac
  38. done
  39. ;;
  40. esac
  41. done < /etc/nsswitch.conf`
  42. local pidfile="$(strings /usr/sbin/nscd | grep nscd.pid)"
  43. mkdir -p "$(dirname ${pidfile})"
  44. save_options pidfile "${pidfile}"
  45. start-stop-daemon --start --quiet \
  46. --exec /usr/sbin/nscd --pidfile "${pidfile}" \
  47. -- $secure
  48. eend $?
  49. }
  50. stop() {
  51. local pidfile="$(get_options pidfile)"
  52. [ -n "${pidfile}" ] && pidfile="--pidfile ${pidfile}"
  53. ebegin "Shutting down Name Service Cache Daemon"
  54. start-stop-daemon --stop --quiet --exec /usr/sbin/nscd ${pidfile}
  55. eend $?
  56. }
  57. # vim:ts=4