Switch to using config files for most settings.
This is to make it easier to juggle all the settings.
This commit is contained in:
parent
5f4939c9e6
commit
26d3f7e736
@ -21,16 +21,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere jail_nat 10.215.1.1/24 /vm/iso/FreeBSD-13.2-RELEASE-amd64-bootonly.iso
|
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere jail_nat 10.215.1.1/24 /vm/iso/FreeBSD-13.2-RELEASE-amd64-bootonly.iso
|
||||||
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere jail_nat 10.215.1.1/24
|
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere jail_nat 10.215.1.1/24
|
||||||
|
|
||||||
|
: ${CPU_CORES:="1"}
|
||||||
|
: ${MEMORY:="1G"}
|
||||||
|
: ${NETWORK:="NAT"} # or RAW
|
||||||
|
: ${IP_RANGE:="10.215.1.1/24"} # Ignored for RAW networks
|
||||||
|
: ${INTERFACE_NAME:="jail_nat"} # or the external interface like lagg0 for RAW networks
|
||||||
|
: ${BRIDGE_NAME:="bridge_$INTERFACE_NAME"} # or bridge_raw for RAW networks
|
||||||
|
|
||||||
function main {
|
function main {
|
||||||
if [ "$1" = "create-disk" ]; then
|
cmd="$1"
|
||||||
shift 1
|
shift 1
|
||||||
|
if [ "$cmd" = "create-disk" ]; then
|
||||||
create_disk "${@}"
|
create_disk "${@}"
|
||||||
elif [ "$1" = "start" ]; then
|
elif [ "$cmd" = "start" ]; then
|
||||||
shift 1
|
|
||||||
start_vm "${@}"
|
start_vm "${@}"
|
||||||
else
|
else
|
||||||
>&2 echo "Unrecognized command"
|
die 1 "Unrecognized command $cmd"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,9 +54,12 @@ function create_disk {
|
|||||||
zfs create -o "mountpoint=$mount_path" "$zfs_path"
|
zfs create -o "mountpoint=$mount_path" "$zfs_path"
|
||||||
cp /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd "${mount_path}/"
|
cp /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd "${mount_path}/"
|
||||||
tee "${mount_path}/settings" <<EOF
|
tee "${mount_path}/settings" <<EOF
|
||||||
CPU_CORES=1
|
CPU_CORES="$CPU_CORES"
|
||||||
MEMORY=1G
|
MEMORY="$MEMORY"
|
||||||
NETWORK=NAT
|
NETWORK="$NETWORK"
|
||||||
|
IP_RANGE="$IP_RANGE"
|
||||||
|
BRIDGE_NAME="$BRIDGE_NAME"
|
||||||
|
INTERFACE_NAME="$INTERFACE_NAME"
|
||||||
EOF
|
EOF
|
||||||
zfs create -s "-V${gigabytes}G" -o volmode=dev "$zfs_path/disk0"
|
zfs create -s "-V${gigabytes}G" -o volmode=dev "$zfs_path/disk0"
|
||||||
}
|
}
|
||||||
@ -59,20 +68,19 @@ function start_vm {
|
|||||||
name="$1"
|
name="$1"
|
||||||
zfs_path="$2"
|
zfs_path="$2"
|
||||||
mount_path="$3"
|
mount_path="$3"
|
||||||
host_interface_name="$4" # for raw, external interface
|
mount_cd="${4:-}"
|
||||||
bridge_name="bridge_${host_interface_name}"
|
|
||||||
ip_range="$5" # for raw this value does not matter
|
|
||||||
mount_cd="${6:-}"
|
|
||||||
|
|
||||||
mac_address=$(calculate_mac_address "$name")
|
|
||||||
|
|
||||||
CPU_CORES=1
|
|
||||||
MEMORY=1G
|
|
||||||
NETWORK="NAT"
|
|
||||||
if [ -e "${mount_path}/settings" ]; then
|
if [ -e "${mount_path}/settings" ]; then
|
||||||
source "${mount_path}/settings"
|
source "${mount_path}/settings"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
host_interface_name="$INTERFACE_NAME" # for raw, external interface
|
||||||
|
bridge_name="$BRIDGE_NAME"
|
||||||
|
ip_range="$IP_RANGE" # for raw this value does not matter
|
||||||
|
|
||||||
|
mac_address=$(calculate_mac_address "$name")
|
||||||
|
|
||||||
|
|
||||||
if [ "$NETWORK" = "NAT" ]; then
|
if [ "$NETWORK" = "NAT" ]; then
|
||||||
assert_bridge "$host_interface_name" "$bridge_name" "$ip_range"
|
assert_bridge "$host_interface_name" "$bridge_name" "$ip_range"
|
||||||
elif [ "$NETWORK" = "RAW" ]; then
|
elif [ "$NETWORK" = "RAW" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user