commit 682ffcc16485cefe8f9982b0e8946303f51fe8e0 from: mischa date: Sun Nov 25 15:55:37 2018 UTC added functions to override ip/ipv6 commit - 2a40c74e5924bdd018867ee33003061ed22fc678 commit + 682ffcc16485cefe8f9982b0e8946303f51fe8e0 blob - 1666cfcc241f9a28f865eb97a0cb45e30d9475b4 blob + bad7045669c0b87f9a7678c7c8eb3a47b20c912b --- _vms.conf +++ _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" blob - 037cba59eb0e19165c8d34f4c0f8291321c6636f blob + 4a6cdf965f4ebfb00ff8bb56045748491a8b5a2e --- deploy.sh +++ 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" blob - 9e865e50d02e38a2a095bfc1787cbf4125cee011 blob + 827b073940d5958346876dd490768ccf9c36a1bc --- vms/vm10.txt +++ 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!!"