nscd.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: utf-8 -*-
  2. from comar.service import *
  3. import os
  4. serviceType = "local"
  5. serviceDesc = _({"en": "Name Service Caching Daemon",
  6. "tr": "İsim Hizmeti Önbellek Sunucusu"})
  7. serviceDefault = "on"
  8. MSG_ERR_STRTSRVC = {"en": "Unable to start service.",
  9. "tr": "Servis başlatılamadı.",
  10. }
  11. RUNDIR = "/var/run/nscd"
  12. DBDIR = "/var/db/nscd"
  13. CONFFILE = "/etc/nscd.conf"
  14. PIDFILE = "%s/nscd.pid" % RUNDIR
  15. SOCKETFILE = "%s/socket" % RUNDIR
  16. @synchronized
  17. def start():
  18. if not os.path.exists(CONFFILE):
  19. fail(_(MSG_ERR_STRTSRVC))
  20. for i in [RUNDIR, DBDIR]:
  21. if not os.path.exists(i):
  22. os.makedirs(i, mode=0755)
  23. startService(command="/usr/sbin/nscd",
  24. pidfile=PIDFILE,
  25. detach=True)
  26. @synchronized
  27. def stop():
  28. stopService(pidfile=PIDFILE,
  29. donotify=True)
  30. # if nscd drops priviledges it can't delete these
  31. for i in [PIDFILE, SOCKETFILE]:
  32. if os.path.exists(i):
  33. os.unlink(i)
  34. def status():
  35. return isServiceRunning(pidfile=PIDFILE)