diff --git a/_vms.conf b/_vms.conf index 1666cfc..bad7045 100644 --- a/_vms.conf +++ b/_vms.conf @@ -16,6 +16,8 @@ HTDOCS="." VMDUSERS="_vmdusers" UPLINK="uplink_vlan42" BRIDGE="bridge42" +UPLINK2="uplink_vlan421" +BRIDGE2="bridge421" # dhcpd.conf ROUTER="192.168.1.1" DNS="192.186.1.3" diff --git a/deploy.sh b/deploy.sh index 037cba5..4a6cdf9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -90,25 +90,43 @@ fetch_mac() { echo "${1}:${2}" } +fetch_switch() { + # Fetch the uplink for the VM. + # Takes the UPLINK and switch. + # print the switch + if test -z "$2" + then echo $1 + else echo $2 + fi +} + fetch_ip() { # Fetch the IP address for the VM. - # Takes the IP_PREFIX, IP_START and VM#. + # Takes the IP_PREFIX, IP_START, VM# and ip. # add IP_START and VM# and print the IP address # print the IP address - _prefix=$1 - _host=$(($2 + $3)) - echo "${_prefix}.${_host}" + if test -z "$4" + then + _prefix=$1 + _host=$(($2 + $3)) + echo "${_prefix}.${_host}" + else echo "$4" + fi } fetch_ipv6() { # Fetch the IPv6 address of the VM. - # Takes the IPV6_PREFIX, IPV6_START, IP_START and VM# + # Takes the IPV6_PREFIX, IPV6_START, IP_START, VM# and ipv6. # add IPV6_START and VM#, IP_START and VM# and print the IPv6 address # print the IPv6 address - _prefix=$1 - _subnet=$(($2 + $4)) - _host=$(($3 + $4)) - echo "${_prefix}:${_subnet}::${_host}" + if test -z "$5" + then + _prefix=$1 + _subnet=$(($2 + $4)) + _host=$(($3 + $4)) + echo "${_prefix}:${_subnet}::${_host}" + else echo "$5" + fi } generate_passwd() { @@ -150,6 +168,8 @@ clear_variables() { unset email unset message unset hostname + unset ip + unset ipv6 unset username unset note } @@ -165,6 +185,12 @@ render_vm_conf() { printf "switch \"%s\" {\\n" "$UPLINK" printf "\\tinterface %s\\n" "$BRIDGE" printf "}\\n\\n" + if ! test -z "$UPLINK2" + then + printf "switch \"%s\" {\\n" "$UPLINK2" + printf "\\tinterface %s\\n" "$BRIDGE2" + printf "}\\n\\n" + fi while read -r f do . "$f" @@ -178,7 +204,8 @@ render_vm_conf() { fi printf "\\tdisk \"%s/%s.img\"\\n" "$IMAGES" "$_instance" printf "\\tinterface tap {\\n" - printf "\\t\\tswitch \"uplink_vlan921\"\\n" + #printf "\\t\\tswitch \"uplink_vlan921\"\\n" + printf "\\t\\tswitch \"$(fetch_switch "$UPLINK" "$switch")\"\\n" printf "\\t\\tlladdr %s\\n" "$(fetch_mac "$MAC_PREFIX" "$(find_vm "$VMS" "$_instance")")" printf "\\t}\\n" printf "}\\n" @@ -206,7 +233,7 @@ render_dhcpd_conf() { _instance=$(check_instance "$f" "$instance") printf "\\thost %s {\\n" "$_instance" printf "\\t\\thardware ethernet %s;\\n" "$(fetch_mac "$MAC_PREFIX" "$(find_vm "$VMS" "$_instance")")" - printf "\\t\\tfixed-address %s;\\n" "$(fetch_ip "$IP_PREFIX" "$IP_START" "$(find_vm "$VMS" "$_instance")")" + printf "\\t\\tfixed-address %s;\\n" "$(fetch_ip "$IP_PREFIX" "$IP_START" "$(find_vm "$VMS" "$_instance")" "$ip")" if ! test -f "${IMAGES}/${_instance}.img" then printf "\\t\\tfilename \"auto_install\";\\n" else printf "\\t\\tfilename \"auto_upgrade\";\\n" @@ -230,7 +257,7 @@ render_install_conf() { . "$f" _instance=$(check_instance "$f" "$instance") _pass="$(generate_passwd)" - _ipv6=$(fetch_ipv6 "$IPV6_PREFIX" "$IPV6_START" "$IP_START" "$(find_vm "$VMS" "$_instance")") + _ipv6=$(fetch_ipv6 "$IPV6_PREFIX" "$IPV6_START" "$IP_START" "$(find_vm "$VMS" "$_instance")" "$ipv6") _ipv6_gateway=$(echo "$_ipv6" | sed -e 's/::[0-9]*$/::1/g') _mac=$(fetch_mac "$MAC_PREFIX" "$(find_vm "$VMS" "$_instance")") if ! test -f "${IMAGES}/${_instance}.img" diff --git a/vms/vm10.txt b/vms/vm10.txt index 9e865e5..827b073 100644 --- a/vms/vm10.txt +++ b/vms/vm10.txt @@ -4,6 +4,8 @@ donated= name="User Ten" email="user.ten@gmail.com" message="ssh-ed25519 AAAAC3NzaC1lAILmSludIBvFRhkxldn1OEgnQdrNd7PxMQjm2DyYCqHjy super-special-key" +switch="uplink_vlan421" +ip="46.23.92.101" hostname="vmten" username="userten" note="This is all awesome!!"