add "gocage get property jail" + "gocage set property jail" now support string, int and bool types

This commit is contained in:
yo
2022-04-03 10:35:48 +02:00
parent 3bedf019dc
commit 139ea18422
2 changed files with 14 additions and 99 deletions

View File

@ -107,6 +107,19 @@ Multiples properties can be specified, separated with space (Ex: gocage set allo
cleanAfterRun()
},
}
getCmd = &cobra.Command{
Use: "get",
Short: "Get a jail property",
Long: `Get jail property value. Specify property, end command with jail name.
Multiples properties can be specified, separated with space (Ex: gocage get allow_mlock boot myjail)`,
Run: func(cmd *cobra.Command, args []string) {
// Get the inventory
ListJails(args, false)
GetJailProperties(args)
cleanAfterRun()
},
}
)
@ -130,6 +143,7 @@ func init() {
listCmd.AddCommand(listPropsCmd)
rootCmd.AddCommand(stopCmd)
rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(getCmd)
rootCmd.AddCommand(setCmd)
// Get FreeBSD version
@ -187,7 +201,6 @@ func initConfig() {
func cleanAfterRun() {
for _, j := range gJails {
if j.ConfigUpdated {
// TODO : Marshall to disk
//fmt.Printf("Config for jail %s will be updated\n", j.Name)
marshaled, err := json.MarshalIndent(j.Config, "", " ")
if err != nil {