From e41b6a619e13f0218ebced3b0dd7e037542629f1 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sat, 23 Nov 2024 20:32:49 -0600 Subject: [PATCH] newvm: Add domain argument Now that we have multiple domains (_pyrocufflink.blue_ for AD domain members and _pyrocufflink.black_ for the new machines), we need a way to specify the domain for new machines when they are created. Thus, the `newvm.sh` script accepts either an FQDN or a `--domain` argument. The DHCP server will register the DNS name in the zone containing the machine's domain name. --- newvm.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/newvm.sh b/newvm.sh index 32ea733..17e4894 100755 --- a/newvm.sh +++ b/newvm.sh @@ -7,6 +7,7 @@ disk_size=16 kickstart=http://rosalina.pyrocufflink.blue/~dustin/kickstart/fedora.ks fedora=$(rpm -E %fedora) network=network=prod +dnsdomain=pyrocufflink.blue console=true usage() { @@ -65,6 +66,13 @@ while [ $# -gt 0 ]; do --network=*) network="${1#*=}" ;; + --domain) + shift + dnsdomain=$1 + ;; + --domain=*) + dnsdomain=${1#=*} + ;; --no-console|--noconsole) console=false ;; @@ -88,6 +96,16 @@ if [ -z "${name}" ]; then exit 2 fi +case ${name} in +*.*) + hostname=${name} + name=${name%%.*} + ;; +*) + hostname=${name}.${dnsdomain} + ;; +esac + if [ -z "${LIBVIRT_DEFAULT_URI}" ]; then printf 'LIBVIRT_DEFAULT_URI is not set.\n' >&2 printf 'If you want to create a new VM locally, explicitly set ' @@ -110,7 +128,7 @@ else printf 'Using HTTP proxy: %s\n' "${http_proxy}" >&2 fi -extra_args="ip=::::${name}::dhcp inst.ks=${kickstart}" +extra_args="ip=::::${hostname}::dhcp inst.ks=${kickstart}" if [ -n "${http_proxy}" ]; then extra_args="${extra_args} inst.proxy=${http_proxy}" if [ ${fedora} -lt 40 ]; then