7 Commits
v0.38 ... v0.39

5 changed files with 39 additions and 23 deletions

View File

@ -1,8 +1,9 @@
package cmd
import (
"errors"
"os"
"fmt"
"errors"
"reflect"
"strconv"
"strings"
@ -20,7 +21,7 @@ func GetJailProperties(args []string) {
jail, err = getJailFromArray(a, []string{""}, gJails)
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
os.Exit(1)
}
} else {
props = append(props, a)
@ -105,20 +106,20 @@ func SetJailProperties(args []string) {
return
}
// Get jail by index to modify it
for i, _ := range gJails {
if gJails[i].Name == jail.Name {
for _, p := range props {
err := setStructFieldValue(&gJails[i], p.name, p.value)
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
} else {
fmt.Printf("%s: %s set to %s\n", gJails[i].Name, p.name, p.value)
gJails[i].ConfigUpdated = true
}
}
writeConfigToDisk(&gJails[i], false)
cj, err := getJailFromArray(jail.Name, []string{""}, gJails)
if err != nil {
fmt.Printf("Error getting jail %s: %v\n", jail.Name, err)
return
}
for _, p := range props {
err := setStructFieldValue(cj, p.name, p.value)
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
} else {
fmt.Printf("%s: %s set to %s\n", cj.Name, p.name, p.value)
}
}
cj.WriteConfigToDisk(false)
}

View File

@ -14,7 +14,7 @@ import (
)
const (
gVersion = "0.38"
gVersion = "0.39"
// TODO : Get from $jail_zpool/defaults.json
MIN_DYN_DEVFS_RULESET = 1000

View File

@ -840,7 +840,7 @@ func setupVnetInterfaceHostSide(jail *Jail) ([]string, error) {
bridge := v[1]
// Get host side MAC
pname := fmt.Sprintf("Config.%s_mac", nic)
pname := fmt.Sprintf("Config.%s_mac", strings.Title(nic))
var val *reflect.Value
val, pname, err = getStructFieldValue(jail, pname)
if err != nil {
@ -853,7 +853,10 @@ func setupVnetInterfaceHostSide(jail *Jail) ([]string, error) {
return []string{}, err
}
} else {
hsmac = val.Bytes()
hsmac, err = hex.DecodeString(strings.Split(val.String(), " ")[0])
if err != nil {
return []string{}, fmt.Errorf("Error converting %s to hex\n", strings.Split(val.String(), " ")[0])
}
}
// Get bridge MTU
@ -934,7 +937,7 @@ func setupVnetInterfaceJailSide(jail *Jail, hostepairs []string) error {
jsepair := fmt.Sprintf("%sb", strings.TrimSuffix(hostepairs[i], "a"))
// Get jail side MAC
pname := fmt.Sprintf("Config.%s_mac", nic)
pname := fmt.Sprintf("Config.%s_mac", strings.Title(nic))
var val *reflect.Value
val, pname, err = getStructFieldValue(jail, pname)
if err != nil {
@ -947,7 +950,11 @@ func setupVnetInterfaceJailSide(jail *Jail, hostepairs []string) error {
return err
}
} else {
jsmac = val.Bytes()
jsmac, err = hex.DecodeString(strings.Split(val.String(), " ")[1])
if err != nil {
return fmt.Errorf("Error converting %s to hex\n", strings.Split(val.String(), " ")[1])
}
}
cmd := fmt.Sprintf("/sbin/ifconfig %s vnet %s", jsepair, jail.InternalName)

View File

@ -5,6 +5,7 @@ import (
"fmt"
//"log"
"time"
"strings"
)
@ -63,6 +64,12 @@ func UpdateJail(args []string) {
continue
}
// We cant update basejail as system is readonly
if strings.EqualFold(cj.Config.Jailtype, "basejail") {
fmt.Printf("%s is a basejail using %s system files. Please update %s!\n", cj.Name, cj.Config.Origin, cj.Config.Origin)
continue
}
fmt.Printf(" > Snapshot jail %s\n", cj.Name)
// Set snapshot name
dt := time.Now()

View File

@ -917,7 +917,8 @@ func getFstab(path string) ([]Mount, error) {
scan := bufio.NewScanner(f)
for scan.Scan() {
res := strings.Fields(scan.Text())
if len(res) != 6 {
// iocage create lines like that : "/iocage/releases/13.2-RELEASE/root/bin /iocage/jails/smtp-router-02/root/bin nullfs ro 0 0 # Added by iocage on 2023-10-10 17:20:51"
if (len(res) > 6 && !strings.EqualFold(res[6], "#")) || len(res) < 6 {
return mounts, fmt.Errorf("Incorrect format for fstab line %s", scan.Text())
}
freq, err := strconv.Atoi(res[4])