diff files/fbhyve.in @ 467:6ecd16725818

Begin refactoring bhyve into fbhyve. Planned: - more consistent naming (analogous to jails) - using bhyve configuration files instead of RC variables for bhyve devices - more docs
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 14 Jun 2024 09:40:04 +0200
parents c8abd9d7aac7
children 57f253106ed6
line wrap: on
line diff
--- a/files/fbhyve.in	Fri Jun 14 08:48:27 2024 +0200
+++ b/files/fbhyve.in	Fri Jun 14 09:40:04 2024 +0200
@@ -1,14 +1,16 @@
 #!/bin/sh
 
-# PROVIDE: bhyve
+# PROVIDE: fbhyve
 # REQUIRE: LOGIN
-# KEYWORD: nojail
+# KEYWORD: shutdown nojail
 #
 
+# @(#)%%SIMPLEVERSIONTAG%%
+
 #
 # Add the following lines to /etc/rc.conf to enable bhyve:
-# bhyve_enable (bool):  Set to "NO" by default.
-#                       Set it to "YES" to enable bhyve
+# fbhyve_enable (bool):  Set to "NO" by default.
+#                        Set it to "YES" to enable bhyve
 # bhyve_profiles (str): Set to "" by default.
 #                       Define your profiles here.
 # bhyve_tapdev (str):   Set to "tap0" by default.
@@ -22,8 +24,8 @@
 
 . /etc/rc.subr
 
-name="bhyve"
-rcvar=bhyve_enable
+name="fbhyve"
+rcvar=fbhyve_enable
 
 start_precmd="bhyve_prestart"
 status_cmd="bhyve_status"
@@ -33,7 +35,6 @@
 command="/usr/local/bin/tmux"
 procname="-sh"
 
-[ -z "$bhyve_enable" ]  && bhyve_enable="NO"
 [ -z "$bhyve_tapdev" ]  && bhyve_tapdev="tap0"
 [ -z "$bhyve_diskdev" ] && bhyve_diskdev="none"
 [ -z "$bhyve_ncpu" ]    && bhyve_ncpu="1"
@@ -41,11 +42,15 @@
 
 load_rc_config $name
 
+: {fbhyve_enable:="NO"}
+: {fbhyve_configdir:="%%PREFIX%%/etc/fbhyve"}
+
+
 if [ -n "$2" ]; then
 	profile="$2"
 	_session="${_session}_${profile}"
 	if [ "x${bhyve_profiles}" != "x" ]; then
-		eval bhyve_enable="\${${_session}_enable:-${bhyve_enable}}"
+		eval fbhyve_enable="\${${_session}_enable:-${fbhyve_enable}}"
 		eval bhyve_tapdev="\${${_session}_tapdev:-${bhyve_tapdev}}"
 		eval bhyve_diskdev="\${${_session}_diskdev:-${bhyve_diskdev}}"
 		eval bhyve_ncpu="\${${_session}_ncpu:-${bhyve_ncpu}}"
@@ -57,7 +62,7 @@
 	if [ "x${bhyve_profiles}" != "x" -a "x$1" != "x" ]; then
 		for profile in ${bhyve_profiles}; do
 			eval _enable="\${bhyve_${profile}_enable}"
-			case "x${_enable:-${bhyve_enable}}" in
+			case "x${_enable:-${fbhyve_enable}}" in
 			x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee])
 				continue
 				;;
@@ -65,12 +70,12 @@
 				;;
 			*)
 				if test -z "$_enable"; then
-					_var=bhyve_enable
+					_var=fbhyve_enable
 				else
 					_var=bhyve_"${profile}"_enable
 				fi
 				echo "Bad value" \
-				    "'${_enable:-${bhyve_enable}}'" \
+				    "'${_enable:-${fbhyve_enable}}'" \
 				    "for ${_var}. " \
 				    "Profile ${profile} skipped."
 				continue