Merge pull request #271 from mslacken/run-exec-exit
execute './.ww4/runExit` on exit of container exec
This commit is contained in:
@@ -85,6 +85,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
_, err = os.Stat("./etc/warewulf/runExit")
|
||||
if os.IsNotExist(err) {
|
||||
wwlog.Printf(wwlog.DEBUG, "no exit script")
|
||||
return nil
|
||||
}
|
||||
wwlog.Printf(wwlog.INFO, "Running exit script %s\n", path.Join(container.RootFsDir(containerName), "./etc/warewulf/runExit"))
|
||||
err = syscall.Exec("./etc/warewulf/runExit", []string{""}, os.Environ())
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user