* nfsd: run rpc.nfsd from the pre-start script since it's not actually

a daemon (it just starts some kernel threads).  In the post-stop
  script, stop the kernel threads.
* exportfs: fix the createMountPoints option.
* Mount the nfsd filesystem on /proc/fs/nfsd because mountd prefers
  this.

svn path=/nixos/branches/boot-order/; revision=22187
This commit is contained in:
Eelco Dolstra 2010-06-08 16:01:31 +00:00
parent 3eac003800
commit a9e8bf6491
2 changed files with 13 additions and 7 deletions

View File

@ -8,6 +8,8 @@ let
cfg = config.services.nfsKernel;
exports = pkgs.writeText "exports" cfg.server.exports;
in
{
@ -82,7 +84,7 @@ in
});
environment.etc = mkIf cfg.server.enable (singleton
{ source = pkgs.writeText "exports" cfg.server.exports;
{ source = exports;
target = "exports";
});
@ -100,19 +102,23 @@ in
''
export PATH=${pkgs.nfsUtils}/sbin:$PATH
mkdir -p /var/lib/nfs
${config.system.sbin.modprobe}/sbin/modprobe nfsd || true
${pkgs.sysvtools}/bin/mountpoint -q /proc/fs/nfsd \
|| ${config.system.sbin.mount}/bin/mount -t nfsd none /proc/fs/nfsd
${optionalString cfg.server.createMountPoints
''
# create export directories:
# skip comments, take first col which may either be a quoted
# "foo bar" or just foo (-> man export)
sed '/^#.*/d;s/^"\([^"]*\)".*/\1/;t;s/[ ].*//' ${cfg.server.exports} \
sed '/^#.*/d;s/^"\([^"]*\)".*/\1/;t;s/[ ].*//' ${exports} \
| xargs -d '\n' mkdir -p
''
}
# exports file is ${cfg.server.exports}
# exports file is ${exports}
# keep this comment so that this job is restarted whenever exports changes!
exportfs -ra
'';
@ -128,7 +134,9 @@ in
startOn = "started nfs-kernel-exports and started portmap";
stopOn = "stopping nfs-kernel-exports";
exec = "${pkgs.nfsUtils}/sbin/rpc.nfsd ${if cfg.server.hostName != null then "-H ${cfg.server.hostName}" else ""} ${builtins.toString cfg.server.nproc}";
preStart = "${pkgs.nfsUtils}/sbin/rpc.nfsd ${if cfg.server.hostName != null then "-H ${cfg.server.hostName}" else ""} ${builtins.toString cfg.server.nproc}";
postStop = "${pkgs.nfsUtils}/sbin/rpc.nfsd 0";
};
}

View File

@ -142,7 +142,7 @@ in
+ " " + fs.fsType
+ " " + fs.options
+ " 0"
+ " " + (if fs.mountPoint == "/" then "1" else "2")
+ " " + (if fs.fsType == "none" then "0" else if fs.mountPoint == "/" then "1" else "2")
+ "\n"
)}
@ -187,8 +187,6 @@ in
task = true;
stopOn = "filesystem";
extraConfig = "console owner";
script =