nscd.initd 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2020 Gentoo Authors
  3. # Distributed under the terms of the GNU General Public License v2
  4. description="The 'Name Service Cache Daemon' is a daemon that provides a cache"
  5. description="${description} for the most common name service requests"
  6. extra_started_commands="flush_all flush_hosts flush_group flush_passwd flush_netgroup flush_services"
  7. description_flush_all="Will invalidate hosts, group, passwd, netgroup and services cache"
  8. description_flush_hosts="Will invalidate hosts cache"
  9. description_flush_group="Will invalidate group cache"
  10. description_flush_passwd="Will invalidate passwd cache"
  11. description_flush_netgroup="Will invalidate netgroup cache"
  12. description_flush_services="Will invalidate services cache"
  13. pidfile="/run/nscd/nscd.pid"
  14. command="/usr/bin/nscd"
  15. depend() {
  16. use dns ldap net slapd logger
  17. }
  18. checkconfig() {
  19. if [ ! -d /run/nscd ] ; then
  20. checkpath -d -m 755 /run/nscd
  21. fi
  22. if [ -z "${NSCD_PERMS_OK}" ] && [ "$(stat -c %a /run/nscd)" != "755" ] ; then
  23. ewarn "nscd run dir is not readable, you should reset the perms:"
  24. ewarn "chmod 755 /run/nscd"
  25. ewarn "chmod a+rw /run/nscd/socket"
  26. ewarn "To disable this warning, set 'NSCD_PERMS_OK' in /etc/conf.d/nscd"
  27. fi
  28. if grep -qs '^[[:space:]]*persistent\>' /etc/nscd.conf ; then
  29. checkpath -d -m 700 /var/db/nscd
  30. fi
  31. }
  32. _flush() {
  33. local table=$1
  34. ebegin "Flushing ${table} table"
  35. ${command} --invalidate ${table}
  36. eend $?
  37. }
  38. flush_all() {
  39. local has_errors=0
  40. ebegin "Flushing all caches"
  41. local table=
  42. for table in passwd group hosts netgroup services; do
  43. ${command} --invalidate ${table}
  44. [ $? -ne 0 ] && has_errors=1
  45. done
  46. eend ${has_errors}
  47. }
  48. flush_hosts() {
  49. _flush hosts
  50. }
  51. flush_group() {
  52. _flush group
  53. }
  54. flush_passwd() {
  55. _flush passwd
  56. }
  57. flush_netgroup() {
  58. _flush netgroup
  59. }
  60. flush_services() {
  61. _flush services
  62. }
  63. start_pre() {
  64. checkconfig
  65. }