node option also for shell and respect env $SHELL
This commit is contained in:
@@ -48,6 +48,11 @@ func runContainedCmd(args []string) error {
|
||||
|
||||
if err := c.Run(); err != nil {
|
||||
fmt.Printf("Command exited non-zero, not rebuilding/updating VNFS image\n")
|
||||
// defer is not called before os.Exit(0)
|
||||
err = os.RemoveAll(tempDir)
|
||||
if err != nil {
|
||||
wwlog.Warn("Couldn't remove temp dir for ephermal mounts:", err)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
return nil
|
||||
@@ -135,3 +140,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
func SetBinds(myBinds []string) {
|
||||
binds = append(binds, myBinds...)
|
||||
}
|
||||
|
||||
func SetNode(myNode string) {
|
||||
nodeName = myNode
|
||||
}
|
||||
|
||||
@@ -26,9 +26,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
allargs = append(allargs, "--bind", b)
|
||||
}
|
||||
*/
|
||||
args = append(args, "/usr/bin/bash")
|
||||
shellName := os.Getenv("SHELL")
|
||||
if shellName == "" {
|
||||
shellName = "/usr/bin/bash"
|
||||
}
|
||||
args = append(args, shellName)
|
||||
allargs = append(allargs, args...)
|
||||
wwlog.Debug("Calling exec with args: %s", allargs)
|
||||
cntexec.SetBinds(binds)
|
||||
cntexec.SetNode(nodeName)
|
||||
return cntexec.CobraRunE(cmd, allargs)
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ var (
|
||||
},
|
||||
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
|
||||
}
|
||||
binds []string
|
||||
binds []string
|
||||
nodeName string
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, "Bind a local path into the container (must exist)")
|
||||
baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
Reference in New Issue
Block a user