mirror of
https://github.com/churchers/vm-bhyve.git
synced 2026-01-06 04:54:36 +01:00
Fix #47 - we need to init before dnsmasq on boot
Bit more tidying up. Really considering setting version to 1.0-beta now Choice between leaving graphics for 1.1, or waiting
This commit is contained in:
@@ -67,9 +67,10 @@ __vm_list(){
|
||||
# 'vm check name'
|
||||
# check name of virtual machine
|
||||
#
|
||||
# @return int 0 if name is valid
|
||||
#
|
||||
__vm_check_name(){
|
||||
echo "$1" | egrep -iqs '^[a-z0-9][.a-z0-9-]{0,14}[a-z0-9]$'
|
||||
[ $? -ne 0 ] && __err "invalid virtual machine name '$1'"
|
||||
}
|
||||
|
||||
# 'vm create'
|
||||
@@ -95,7 +96,7 @@ __vm_create(){
|
||||
_name=$1
|
||||
|
||||
[ -z "${_name}" ] && __usage
|
||||
__vm_check_name "${_name}"
|
||||
__vm_check_name "${_name}" || __err "invalid virtual machine name - '${_name}'"
|
||||
|
||||
# use default.conf template if none specified
|
||||
: ${_template:=default}
|
||||
@@ -498,7 +499,7 @@ __vm_rename(){
|
||||
[ ! -e "${vm_dir}/${_old}/${_old}.conf" ] && __err "${_old} doesn't appear to be a valid virtual machine"
|
||||
[ -d "${vm_dir}/${_new}" ] && __err "directory ${vm_dir}/${_new} already exists"
|
||||
|
||||
__vm_check_name "${_new}"
|
||||
__vm_check_name "${_new}" || __err "invalid virtual machine name - '${_name}'"
|
||||
|
||||
# confirm guest stopped
|
||||
__vm_confirm_stopped "${_old}" || exit 1
|
||||
|
||||
@@ -122,8 +122,7 @@ __switch_create(){
|
||||
local _switch="$1"
|
||||
local _id _curr_list _curr
|
||||
|
||||
echo "${_switch}" | egrep -iqs '^[a-z0-9][a-z0-9\_\-\.]{0,14}[a-z0-9]$'
|
||||
[ $? -ne 0 ] && __err "invalid switch name"
|
||||
__vm_check_name "${_switch}" || __err "invalid switch name - '${_name}'"
|
||||
|
||||
_curr_list=$(sysrc -inqf "${vm_dir}/.config/switch" switch_list)
|
||||
|
||||
@@ -150,15 +149,13 @@ __switch_import(){
|
||||
local _exists
|
||||
|
||||
[ -z "${_switch}" -o -z "${_bridge}" ] && __usage
|
||||
__vm_check_name "${_switch}" || __err "invalid switch name - '${_name}'"
|
||||
|
||||
echo "${_switch}" | egrep -iqs '^[a-z0-9][a-z0-9\_\-\.]{0,14}[a-z0-9]$'
|
||||
[ $? -ne 0 ] && __err "invalid switch name"
|
||||
_curr_list=$(sysrc -inqf "${vm_dir}/.config/switch" switch_list)
|
||||
|
||||
_curr_list=$(sysrc -inqf "${vm_dir}/.config/switch" switch_list)
|
||||
|
||||
for _curr in $_curr_list; do
|
||||
[ "${_switch}" = "${_curr}" ] && __err "switch ${_switch} already exists"
|
||||
done
|
||||
for _curr in $_curr_list; do
|
||||
[ "${_switch}" = "${_curr}" ] && __err "switch ${_switch} already exists"
|
||||
done
|
||||
|
||||
_exists=$(ifconfig | grep "^${_bridge}: ")
|
||||
[ -z "${_exists}" ] && __err "${_bridge} does not appear to be a valid existing bridge"
|
||||
@@ -525,17 +522,15 @@ __switch_nat_init(){
|
||||
# interfaces are created on demand when starting guests,
|
||||
# and vale switches are dynamic
|
||||
#
|
||||
# @return int 0 is switch is vale
|
||||
#
|
||||
__switch_is_vale(){
|
||||
local _switch="$1"
|
||||
local _is_vale=$(sysrc -inqf "${vm_dir}/.config/switch" "vale_${_switch}")
|
||||
|
||||
[ -z "${_is_vale}" ] && return 1
|
||||
|
||||
if __checkyesno "${_is_vale}"; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
__checkyesno "${_is_vale}"
|
||||
}
|
||||
|
||||
# gets a unique port name for a vale interface
|
||||
@@ -595,9 +590,6 @@ __switch_get_ident(){
|
||||
local _c_id
|
||||
|
||||
# search ifconfig for our switch id, and pull bridge interface name from preceeding line
|
||||
# we've got rid of trailing '-' on switch names but on vm-bhyve upgrade, before host reboot, users may still have them
|
||||
_c_id=$(ifconfig -a | grep -B 1 "vm-${_switch}\$" | head -n 1 | awk -F: '{print $1}')
|
||||
[ -z "${_c_id}" ] && _c_id=$(ifconfig -a | grep -B 1 "vm-${_switch}-\$" | head -n 1 | awk -F: '{print $1}')
|
||||
|
||||
setvar "${_var}" "${_c_id}"
|
||||
}
|
||||
|
||||
3
rc.d/vm
3
rc.d/vm
@@ -3,7 +3,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# PROVIDE: vm
|
||||
# REQUIRE: NETWORKING SERVERS DAEMON LOGIN
|
||||
# REQUIRE: NETWORKING SERVERS
|
||||
# BEFORE: dnsmasq
|
||||
# KEYWORD: shutdown nojail
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
3
vm
3
vm
@@ -24,7 +24,7 @@
|
||||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
VERSION=0.12.13
|
||||
VERSION=0.12.14
|
||||
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
|
||||
BSD_VERSION=$(uname -K)
|
||||
|
||||
@@ -77,4 +77,5 @@ __zfs_init
|
||||
[ ! -d "${vm_dir}/.templates" ] && mkdir "${vm_dir}/.templates"
|
||||
[ ! -d "${vm_dir}/.iso" ] && mkdir "${vm_dir}/.iso"
|
||||
|
||||
# run the requested command
|
||||
__parse_cmd ${VM_COMMAND}
|
||||
|
||||
Reference in New Issue
Block a user