Initialise gJailHost
This commit is contained in:
parent
1bc248fdcc
commit
f919ff2ec3
15
cmd/root.go
15
cmd/root.go
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@ -22,6 +21,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
gJailHost JailHost
|
||||
gJails []Jail
|
||||
gDatastores []Datastore
|
||||
|
||||
@ -261,6 +261,8 @@ You can specify multiple datastores.`,
|
||||
|
||||
// TODO : Init log level and log output
|
||||
func init() {
|
||||
var err error
|
||||
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
// Global switches
|
||||
@ -320,14 +322,12 @@ func init() {
|
||||
migrateCmd.AddCommand(migrateCleanCmd)
|
||||
datastoreCmd.AddCommand(datastoreListCmd)
|
||||
|
||||
// Get FreeBSD version
|
||||
out, err := executeCommand("freebsd-version")
|
||||
// Get FreeBSD version, hostname, hostid
|
||||
gJailHost, err = NewJailHost()
|
||||
if err != nil {
|
||||
fmt.Printf("Error running \"freebsd-version\": %s", err.Error())
|
||||
fmt.Printf("Error initializing JailHost properties: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
gHostVersion, _ = strconv.ParseFloat(strings.Split(out, "-")[0], 32)
|
||||
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
@ -336,8 +336,6 @@ func initConfig() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// fmt.Printf("We are in initConfig(), with config file %s\n", gConfigFile)
|
||||
|
||||
viper.SetConfigFile(gConfigFile)
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
@ -400,6 +398,7 @@ func initConfig() {
|
||||
func WriteConfigToDisk(changeauto bool) {
|
||||
for _, j := range gJails {
|
||||
if j.ConfigUpdated {
|
||||
//log.Debug("%s config has changed, write changes to disk\n", j.Name)
|
||||
|
||||
// we will manipulate properties so get a copy
|
||||
jc := j.Config
|
||||
|
Loading…
Reference in New Issue
Block a user