service.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. from comar.service import *
  3. import os
  4. serviceType = "local"
  5. serviceDesc = _({"en": "Network Manager",
  6. "tr": "Ağ Yöneticisi Hizmeti"})
  7. serviceDefault = "conditional"
  8. MSG_BACKEND_WARNING = _({
  9. "en" : "NetworkManager is not enabled by default. You can change this from /etc/conf.d/NetworkManager.",
  10. "tr" : "NetworkManager öntanımlı olarak etkin değil. /etc/conf.d/NetworkManager dosyasından bu ayarı değiştirebilirsiniz."
  11. })
  12. PIDFILE="/run/NetworkManager/NetworkManager.pid"
  13. USETHIS=eval(config.get("DEFAULT", "True"))
  14. @synchronized
  15. def start():
  16. if not USETHIS:
  17. fail(MSG_BACKEND_WARNING)
  18. startService(command="/usr/sbin/NetworkManager",
  19. args="--pid-file=%s" % PIDFILE,
  20. donotify=True)
  21. @synchronized
  22. def stop():
  23. stopService(pidfile=PIDFILE,
  24. donotify=True)
  25. try:
  26. os.unlink(PIDFILE)
  27. except:
  28. pass
  29. def ready():
  30. if not USETHIS:
  31. fail(MSG_BACKEND_WARNING)
  32. else:
  33. start()
  34. def status():
  35. return isServiceRunning(pidfile=PIDFILE)