#!/usr/local/bin/bash # set -euo pipefail IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function main { if [ "$1" = "create-disk" ]; then shift 1 create_disk "${@}" elif [ "$1" = "start" ]; then shift 1 start_vm "${@}" else >&2 echo "Unrecognized command" exit 1 fi } function create_disk { zfs_path="$1" mount_path="$2" gigabytes="$3" zfs create -o "mountpoint=$mount_path" "$zfs_path" cp /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd "${mount_path}/" tee "${mount_path}/settings" <&2 echo "No available links on bridge $bridge_name") exit 1 fi done } function assert_bridge { host_interface_name="$1" bridge_name="$2" ip_range="$3" if ! ng_exists "${bridge_name}:"; then ngctl -d -f - </dev/null 2>&1 } function calculate_mac_address { name="$1" source=$(md5 -r -s "$name" | awk '{print $1}') echo "${source:0:2}:${source:2:2}:${source:4:2}:${source:6:2}:${source:8:2}:${source:10:2}" } main "${@}"