Merge pull request #2385 from betabrand/hyperkit-nfs-cleanupexports

Cleanup NFS Exports after stop and delete
pull/2390/head
Matt Rickard 2018-01-04 10:09:46 -08:00 committed by GitHub
commit 80b949d64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -230,6 +230,7 @@ func (d *Driver) Start() error {
// Stop a host gracefully
func (d *Driver) Stop() error {
d.cleanupNfsExports()
return d.sendSignal(syscall.SIGTERM)
}
@ -327,3 +328,18 @@ func (d *Driver) getPid() int {
return config.Pid
}
func (d *Driver) cleanupNfsExports() {
if len(d.NFSShares) > 0 {
log.Infof("You must be root to remove NFS shared folders. Please type root password.")
for _, share := range d.NFSShares {
if _, err := nfsexports.Remove("", d.nfsExportIdentifier(share)); err != nil {
log.Errorf("failed removing nfs share (%s): %s", share, err.Error())
}
}
if err := nfsexports.ReloadDaemon(); err != nil {
log.Errorf("failed to reload the nfs daemon: %s", err.Error())
}
}
}