updateVersion now can be used on stopped jail
This commit is contained in:
parent
c2277ce10c
commit
44b877eae1
17
cmd/utils.go
17
cmd/utils.go
@ -474,6 +474,8 @@ func executeCommandWithOutputToStdout(cmdline string) (error) {
|
|||||||
word = word + string(c)
|
word = word + string(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("executeCommandWithOutputToStdout: will execute \"%s\"\n", strings.Join(cmd, " "))
|
||||||
|
|
||||||
var execHandle *exec.Cmd
|
var execHandle *exec.Cmd
|
||||||
if len(cmd) > 1 {
|
if len(cmd) > 1 {
|
||||||
execHandle = exec.Command(cmd[0], cmd[1:]...)
|
execHandle = exec.Command(cmd[0], cmd[1:]...)
|
||||||
@ -1062,7 +1064,7 @@ func getJailFromArray(name string, jailtypes []string, jarray []Jail) (*Jail, er
|
|||||||
var jails []Jail
|
var jails []Jail
|
||||||
|
|
||||||
if (len(jailtypes) == 1 && len(jailtypes[0]) == 0) || len(jailtypes) == 0 {
|
if (len(jailtypes) == 1 && len(jailtypes[0]) == 0) || len(jailtypes) == 0 {
|
||||||
jailtypes = []string{"jail", "basetpl"}
|
jailtypes = []string{"basejail", "jail", "template"}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(name, "/") {
|
if strings.Contains(name, "/") {
|
||||||
@ -1128,15 +1130,24 @@ func setJailConfigUpdated(jail *Jail) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVersion(jail *Jail) (string, error) {
|
||||||
|
cvers, err := executeCommand(fmt.Sprintf("%s/bin/freebsd-version", jail.RootPath))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("ERROR: %s\n", err.Error())
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.TrimRight(cvers, "\n"), nil
|
||||||
|
}
|
||||||
|
|
||||||
func updateVersion(jail *Jail) error {
|
func updateVersion(jail *Jail) error {
|
||||||
cvers, err := executeCommandInJail(jail, "/bin/freebsd-version")
|
cvers, err := executeCommand(fmt.Sprintf("%s/bin/freebsd-version", jail.RootPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: %s\n", err.Error())
|
fmt.Printf("ERROR: %s\n", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cvers = strings.TrimRight(cvers, "\n")
|
cvers = strings.TrimRight(cvers, "\n")
|
||||||
jail.Config.Release = cvers
|
jail.Config.Release = cvers
|
||||||
writeConfigToDisk(jail, false)
|
jail.WriteConfigToDisk(false)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user