add getBridgeMembers(), Fix Vnet on by default

This commit is contained in:
yo 2024-09-22 17:34:50 +02:00
parent 259c3ee1e0
commit c19e40b139

View File

@ -228,7 +228,7 @@ CreateBootEnv no
"type": "jail",
"used": "readonly",
"vmemoryuse": "off",
"vnet": 0,
"vnet": 1,
"vnet0_mac": "none",
"vnet1_mac": "none",
"vnet2_mac": "none",
@ -751,6 +751,30 @@ func executeScript(script string) (string, error) {
return string(out), err
}
/*****************************************************************************
*
* Network related operations
*
*****************************************************************************/
func getBridgeMembers(bridge string) ([]string, error) {
var members []string
cmd := fmt.Sprintf("/sbin/ifconfig %s", bridge)
out, err := executeCommand(cmd)
if err != nil {
return members, errors.New(fmt.Sprintf("%v; command returned \"%s\"", err, out))
}
for _, line := range strings.Split(out, "\n") {
if strings.HasPrefix(strings.TrimLeft(line, " \t"), "member:") {
m := strings.Split(strings.TrimLeft(strings.Split(line, ":")[1], " "), " ")[0]
log.Debugf("%s is member of %s\n", m, bridge)
members = append(members, m)
}
}
return members, nil
}
/*****************************************************************************
*
* ZFS datasets/pools operations
@ -1033,6 +1057,7 @@ func addRcKeyValue(rcconfpath string, key string, value string) error {
}
return nil
}
/*****************************************************************************
* Parse an fstab file, returning an array of Mount
*****************************************************************************/