new packages: nfs-utils, libgssglue, rpcbind
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from comar.service import *
|
||||
from pardus import fstabutils
|
||||
import os
|
||||
|
||||
serviceType = "server"
|
||||
serviceDesc = _({"en": "NFS Common Services",
|
||||
"tr": "NFS Ortak Servisleri"})
|
||||
|
||||
serviceConf = "nfs"
|
||||
|
||||
ERR_INSMOD = _({"en": "Failed probing module %s",
|
||||
"tr": "%s modülü yüklenemedi",
|
||||
})
|
||||
|
||||
ERR_RMMOD = _({"en": "Failed removing module %s",
|
||||
"tr": "%s modülü çıkarılamadı",
|
||||
})
|
||||
|
||||
PIPEFS_MOUNTPOINT = "/var/lib/nfs/rpc_pipefs"
|
||||
|
||||
STATD_PIDFILE = "/run/rpc.statd.pid"
|
||||
IDMAPD_PIDFILE = "/run/rpc.idmapd.pid"
|
||||
GSSD_PIDFILE = "/run/rpc.gssd.pid"
|
||||
|
||||
# Parse the fstab file and determine whether we need gssd or not, by searching
|
||||
# mount option sec=krb* in nfs mount entries.
|
||||
# If none, nfs conf.d file decides if it's needed.
|
||||
def need_gssd():
|
||||
fstab = fstabutils.Fstab()
|
||||
for entry in fstab.get_entries():
|
||||
if entry.is_nfs():
|
||||
if "sec=krb" in entry.get_fs_mntopts():
|
||||
return True
|
||||
|
||||
@synchronized
|
||||
def start():
|
||||
startDependencies("rpcbind")
|
||||
|
||||
# Set the ports lockd should listen on
|
||||
LOCKD_TCPPORT = config.get("LOCKD_TCPPORT")
|
||||
if LOCKD_TCPPORT:
|
||||
run("/sbin/sysctl -w fs.nfs.nlm_tcpport=%s" % LOCKD_TCPPORT)
|
||||
|
||||
LOCKD_UDPPORT = config.get("LOCKD_UDPPORT")
|
||||
if LOCKD_UDPPORT:
|
||||
run("/sbin/sysctl -w fs.nfs.nlm_udpport=%s" % LOCKD_UDPPORT)
|
||||
|
||||
# rpc.statd is first
|
||||
RPCSTATD_OPTIONS = config.get("RPCSTATD_OPTIONS", "")
|
||||
STATD_PORT = config.get("STATD_PORT")
|
||||
if STATD_PORT:
|
||||
RPCSTATD_OPTIONS += " -p %s" % STATD_PORT
|
||||
|
||||
startService(command="/sbin/rpc.statd",
|
||||
args="%s" % RPCSTATD_OPTIONS,
|
||||
donotify=True,
|
||||
pidfile=STATD_PIDFILE)
|
||||
|
||||
if config.get("NEED_IDMAPD", "yes") == "yes" or (config.get("NEED_GSSD", "no") == "yes" or need_gssd()):
|
||||
if run("/sbin/modprobe -q nfs"):
|
||||
fail(ERR_INSMOD % "nfs")
|
||||
|
||||
# Make sure the mointpoint exists
|
||||
if not os.path.exists(PIPEFS_MOUNTPOINT):
|
||||
os.makedirs(PIPEFS_MOUNTPOINT)
|
||||
|
||||
# Check if PIPEFS_MOUNTPOINT is a real mounted fs
|
||||
if run("/bin/mountpoint -q %s" % PIPEFS_MOUNTPOINT):
|
||||
run("/bin/mount -t rpc_pipefs rpc_pipefs %s" % PIPEFS_MOUNTPOINT)
|
||||
|
||||
startService(command="/usr/sbin/rpc.idmapd",
|
||||
args="-f %s" % config.get("RPCIDMAPD_OPTIONS", ""),
|
||||
donotify=True,
|
||||
detach=True,
|
||||
makepid=True,
|
||||
pidfile=IDMAPD_PIDFILE)
|
||||
|
||||
if config.get("NEED_GSSD", "no") == "yes" or need_gssd():
|
||||
if run("/sbin/modprobe -q rpcsec_gss_krb5"):
|
||||
fail(ERR_INSMOD % "rpcsec_gss_krb5")
|
||||
|
||||
startService(command="/usr/sbin/rpc.gssd",
|
||||
args="-f %s" % config.get("RPCGSSD_OPTIONS", ""),
|
||||
donotify=True,
|
||||
detach=True,
|
||||
makepid=True,
|
||||
pidfile=GSSD_PIDFILE)
|
||||
|
||||
@synchronized
|
||||
def stop():
|
||||
LOCKD_TCPPORT = config.get("LOCKD_TCPPORT")
|
||||
if LOCKD_TCPPORT:
|
||||
run("/sbin/sysctl -w fs.nfs.nlm_tcpport=0")
|
||||
|
||||
LOCKD_UDPPORT = config.get("LOCKD_UDPPORT")
|
||||
if LOCKD_UDPPORT:
|
||||
run("/sbin/sysctl -w fs.nfs.nlm_udpport=0")
|
||||
|
||||
stopService(pidfile=GSSD_PIDFILE,
|
||||
donotify=True)
|
||||
|
||||
stopService(pidfile=IDMAPD_PIDFILE,
|
||||
donotify=True)
|
||||
|
||||
stopService(pidfile=STATD_PIDFILE,
|
||||
donotify=True)
|
||||
|
||||
if not run("/bin/mountpoint -q %s" % PIPEFS_MOUNTPOINT):
|
||||
run("/bin/umount %s" % PIPEFS_MOUNTPOINT)
|
||||
|
||||
def status():
|
||||
result = isServiceRunning(STATD_PIDFILE)
|
||||
if config.get("NEED_IDMAPD", "yes") == "yes":
|
||||
result = result and isServiceRunning(IDMAPD_PIDFILE)
|
||||
if config.get("NEED_GSSD", "no") == "yes" or need_gssd():
|
||||
result = result and isServiceRunning(GSSD_PIDFILE)
|
||||
return result
|
||||
@@ -0,0 +1,130 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from comar.service import *
|
||||
from pardus import fstabutils
|
||||
import signal
|
||||
import os
|
||||
|
||||
serviceType = "server"
|
||||
serviceDesc = _({"en": "NFS Server",
|
||||
"tr": "NFS Sunucusu"})
|
||||
|
||||
serviceConf = "nfs"
|
||||
|
||||
ERR_INSMOD = _({"en": "Failed probing module %s",
|
||||
"tr": "%s modülü yüklenemedi",
|
||||
})
|
||||
|
||||
PROCNFSD_MOUNTPOINT = "/proc/fs/nfsd"
|
||||
RQUOTAD_PATH = "/usr/sbin/rpc.rquotad"
|
||||
|
||||
IDMAPD_PIDFILE = "/run/rpc.idmapd.pid"
|
||||
SVCGSSD_PIDFILE = "/run/rpc.svcgssd.pid"
|
||||
RQUOTAD_PIDFILE = "/run/rpc.rquotad.pid"
|
||||
MOUNTD_PIDFILE = "/run/rpc.mountd.pid"
|
||||
|
||||
# Parse the fstab file and determine whether we need quotad or not by searching
|
||||
# mount option quota in any mount entry.
|
||||
# If none, nfs conf.d file decides if it's needed.
|
||||
def need_quotad():
|
||||
fstab = fstabutils.Fstab()
|
||||
for entry in fstab.get_entries():
|
||||
if "quota" in entry.get_fs_mntopts():
|
||||
return True
|
||||
|
||||
@synchronized
|
||||
def start():
|
||||
startDependencies("nfs_common")
|
||||
|
||||
if run("/sbin/modprobe -q nfsd"):
|
||||
fail(ERR_INSMOD % "nfsd")
|
||||
|
||||
# Check if PROCNFSD_MOUNTPOINT is mounted
|
||||
if run("/bin/mountpoint -q %s" % PROCNFSD_MOUNTPOINT):
|
||||
run("/bin/mount -t nfsd nfsd %s" % PROCNFSD_MOUNTPOINT)
|
||||
|
||||
run("/usr/sbin/exportfs -r")
|
||||
|
||||
# If RPCNFSDCOUNT is not explicitly defined in confd, use default one, 8 threads.
|
||||
startService(command="/usr/sbin/rpc.nfsd",
|
||||
args="%s %s" % (config.get("RPCNFSD_OPTIONS", ""), config.get("RPCNFSDCOUNT", "8")),
|
||||
donotify=True)
|
||||
|
||||
if config.get("NEED_SVCGSSD", "no") == "yes":
|
||||
startService(command="/usr/sbin/rpc.svcgssd",
|
||||
args="-f %s" % config.get("RPCSVCGSSD_OPTIONS", ""),
|
||||
donotify=True,
|
||||
detach=True,
|
||||
makepid=True,
|
||||
pidfile=SVCGSSD_PIDFILE)
|
||||
|
||||
# Start rpc.rquotad daemon here if its available
|
||||
if (config.get("NEED_QUOTAD", "no") == "yes" or need_quotad()) and os.path.exists(RQUOTAD_PATH):
|
||||
RPCRQUOTAD_OPTIONS = config.get("RPCRQUOTAD_OPTIONS", "")
|
||||
RQUOTAD_PORT = config.get("RQUOTAD_PORT")
|
||||
if RQUOTAD_PORT:
|
||||
RPCRQUOTAD_OPTIONS += " -p %s" % RQUOTAD_PORT
|
||||
startService(command=RQUOTAD_PATH,
|
||||
args="-F %s" % RPCRQUOTAD_OPTIONS,
|
||||
donotify=True,
|
||||
detach=True,
|
||||
makepid=True,
|
||||
pidfile=RQUOTAD_PIDFILE)
|
||||
|
||||
# Reload rpc.idmapd
|
||||
if os.path.exists(IDMAPD_PIDFILE):
|
||||
os.kill(int(file(IDMAPD_PIDFILE).read().strip()), signal.SIGHUP)
|
||||
|
||||
RPCMOUNTD_OPTIONS = config.get("RPCMOUNTD_OPTIONS", "")
|
||||
MOUNTD_PORT = config.get("MOUNTD_PORT")
|
||||
if MOUNTD_PORT:
|
||||
RPCMOUNTD_OPTIONS += " -p %s" % MOUNTD_PORT
|
||||
|
||||
startService(command="/usr/sbin/rpc.mountd",
|
||||
args="-F %s" % RPCMOUNTD_OPTIONS,
|
||||
donotify=True,
|
||||
detach=True,
|
||||
makepid=True,
|
||||
pidfile=MOUNTD_PIDFILE)
|
||||
|
||||
@synchronized
|
||||
def stop():
|
||||
stopService(pidfile=MOUNTD_PIDFILE,
|
||||
donotify=True)
|
||||
|
||||
if os.path.exists(MOUNTD_PIDFILE):
|
||||
os.unlink(MOUNTD_PIDFILE)
|
||||
|
||||
stopService(pidfile=SVCGSSD_PIDFILE,
|
||||
donotify=True)
|
||||
|
||||
if os.path.exists(SVCGSSD_PIDFILE):
|
||||
os.unlink(SVCGSSD_PIDFILE)
|
||||
|
||||
stopService(pidfile=RQUOTAD_PIDFILE,
|
||||
donotify=True)
|
||||
|
||||
if os.path.exists(RQUOTAD_PIDFILE):
|
||||
os.unlink(RQUOTAD_PIDFILE)
|
||||
|
||||
stopService(command="/usr/sbin/rpc.nfsd",
|
||||
args="0",
|
||||
donotify=True)
|
||||
|
||||
# Unexport all exported directories
|
||||
run("/usr/sbin/exportfs -au")
|
||||
|
||||
if not run("/bin/mountpoint -q %s" % PROCNFSD_MOUNTPOINT):
|
||||
run("/usr/sbin/exportfs -f %s" % PROCNFSD_MOUNTPOINT)
|
||||
|
||||
def reload():
|
||||
# Re-export all exported directories
|
||||
run("/usr/sbin/exportfs -r")
|
||||
|
||||
def status():
|
||||
# ugly way of learning if the daemon is up and running.
|
||||
result = not run("/sbin/pidof nfsd") and isServiceRunning(MOUNTD_PIDFILE)
|
||||
if config.get("NEED_SVCGSSD", "no") == "yes":
|
||||
result = result and isServiceRunning(SVCGSSD_PIDFILE)
|
||||
if (config.get("NEED_QUOTAD", "no") == "yes" or need_quotad()) and os.path.exists(RQUOTAD_PATH):
|
||||
result = result and isServiceRunning(RQUOTAD_PIDFILE)
|
||||
return result
|
||||
Reference in New Issue
Block a user