Files
core/hardware/disk/mdadm/comar/service.py
T
Ertuğrul Erata 8e13c775be core updated.
2015-05-17 16:28:10 +03:00

43 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from comar.service import *
serviceType = "server"
serviceDesc = _({"en": "RAID monitor daemon",
"tr": "RAID izleme servisi"})
serviceConf = "mdadm"
MSG_ERR_STRTSRVC = {"en": "Couldn't start service.Please edit mdadm.conf file.",
"tr": "Servis başlatılamadı.Lütfen mdadm.conf dosyasını düzenleyiniz.",
}
def check():
try:
f = file("/etc/mdadm.conf")
confLines = [a.lstrip() for a in f]
confLines = filter(lambda x: not (x.startswith("\#") or x == ""), confLines)
check = False
for line in confLines:
if "MAILADDR" or "PROGRAM" in line.split():
check = True
if not check:
fail(MSG_ERR_STRTSRVC)
except:
fail(MSG_ERR_STRTSRVC)
finally:
f.close()
@synchronized
def start():
check()
startService(command="/sbin/mdadm",
args="--monitor --scan --daemonise --pid-file /run/mdadm.pid %s" % config.get("MDADM_OPTS"),
pidfile="/run/mdadm.pid",
donotify=True)
@synchronized
def stop():
stopService(pidfile="/run/mdadm.pid",
donotify=True)
def status():
return isServiceRunning("/run/mdadm.pid")