added functions to override ip/ipv6
This commit is contained in:
parent
2a40c74e59
commit
682ffcc164
@ -16,6 +16,8 @@ HTDOCS="."
|
|||||||
VMDUSERS="_vmdusers"
|
VMDUSERS="_vmdusers"
|
||||||
UPLINK="uplink_vlan42"
|
UPLINK="uplink_vlan42"
|
||||||
BRIDGE="bridge42"
|
BRIDGE="bridge42"
|
||||||
|
UPLINK2="uplink_vlan421"
|
||||||
|
BRIDGE2="bridge421"
|
||||||
# dhcpd.conf
|
# dhcpd.conf
|
||||||
ROUTER="192.168.1.1"
|
ROUTER="192.168.1.1"
|
||||||
DNS="192.186.1.3"
|
DNS="192.186.1.3"
|
||||||
|
51
deploy.sh
51
deploy.sh
@ -90,25 +90,43 @@ fetch_mac() {
|
|||||||
echo "${1}:${2}"
|
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_ip() {
|
||||||
# Fetch the IP address for the VM.
|
# 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
|
# add IP_START and VM# and print the IP address
|
||||||
# print the IP address
|
# print the IP address
|
||||||
_prefix=$1
|
if test -z "$4"
|
||||||
_host=$(($2 + $3))
|
then
|
||||||
echo "${_prefix}.${_host}"
|
_prefix=$1
|
||||||
|
_host=$(($2 + $3))
|
||||||
|
echo "${_prefix}.${_host}"
|
||||||
|
else echo "$4"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch_ipv6() {
|
fetch_ipv6() {
|
||||||
# Fetch the IPv6 address of the VM.
|
# 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
|
# add IPV6_START and VM#, IP_START and VM# and print the IPv6 address
|
||||||
# print the IPv6 address
|
# print the IPv6 address
|
||||||
_prefix=$1
|
if test -z "$5"
|
||||||
_subnet=$(($2 + $4))
|
then
|
||||||
_host=$(($3 + $4))
|
_prefix=$1
|
||||||
echo "${_prefix}:${_subnet}::${_host}"
|
_subnet=$(($2 + $4))
|
||||||
|
_host=$(($3 + $4))
|
||||||
|
echo "${_prefix}:${_subnet}::${_host}"
|
||||||
|
else echo "$5"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_passwd() {
|
generate_passwd() {
|
||||||
@ -150,6 +168,8 @@ clear_variables() {
|
|||||||
unset email
|
unset email
|
||||||
unset message
|
unset message
|
||||||
unset hostname
|
unset hostname
|
||||||
|
unset ip
|
||||||
|
unset ipv6
|
||||||
unset username
|
unset username
|
||||||
unset note
|
unset note
|
||||||
}
|
}
|
||||||
@ -165,6 +185,12 @@ render_vm_conf() {
|
|||||||
printf "switch \"%s\" {\\n" "$UPLINK"
|
printf "switch \"%s\" {\\n" "$UPLINK"
|
||||||
printf "\\tinterface %s\\n" "$BRIDGE"
|
printf "\\tinterface %s\\n" "$BRIDGE"
|
||||||
printf "}\\n\\n"
|
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
|
while read -r f
|
||||||
do
|
do
|
||||||
. "$f"
|
. "$f"
|
||||||
@ -178,7 +204,8 @@ render_vm_conf() {
|
|||||||
fi
|
fi
|
||||||
printf "\\tdisk \"%s/%s.img\"\\n" "$IMAGES" "$_instance"
|
printf "\\tdisk \"%s/%s.img\"\\n" "$IMAGES" "$_instance"
|
||||||
printf "\\tinterface tap {\\n"
|
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\\tlladdr %s\\n" "$(fetch_mac "$MAC_PREFIX" "$(find_vm "$VMS" "$_instance")")"
|
||||||
printf "\\t}\\n"
|
printf "\\t}\\n"
|
||||||
printf "}\\n"
|
printf "}\\n"
|
||||||
@ -206,7 +233,7 @@ render_dhcpd_conf() {
|
|||||||
_instance=$(check_instance "$f" "$instance")
|
_instance=$(check_instance "$f" "$instance")
|
||||||
printf "\\thost %s {\\n" "$_instance"
|
printf "\\thost %s {\\n" "$_instance"
|
||||||
printf "\\t\\thardware ethernet %s;\\n" "$(fetch_mac "$MAC_PREFIX" "$(find_vm "$VMS" "$_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"
|
if ! test -f "${IMAGES}/${_instance}.img"
|
||||||
then printf "\\t\\tfilename \"auto_install\";\\n"
|
then printf "\\t\\tfilename \"auto_install\";\\n"
|
||||||
else printf "\\t\\tfilename \"auto_upgrade\";\\n"
|
else printf "\\t\\tfilename \"auto_upgrade\";\\n"
|
||||||
@ -230,7 +257,7 @@ render_install_conf() {
|
|||||||
. "$f"
|
. "$f"
|
||||||
_instance=$(check_instance "$f" "$instance")
|
_instance=$(check_instance "$f" "$instance")
|
||||||
_pass="$(generate_passwd)"
|
_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')
|
_ipv6_gateway=$(echo "$_ipv6" | sed -e 's/::[0-9]*$/::1/g')
|
||||||
_mac=$(fetch_mac "$MAC_PREFIX" "$(find_vm "$VMS" "$_instance")")
|
_mac=$(fetch_mac "$MAC_PREFIX" "$(find_vm "$VMS" "$_instance")")
|
||||||
if ! test -f "${IMAGES}/${_instance}.img"
|
if ! test -f "${IMAGES}/${_instance}.img"
|
||||||
|
@ -4,6 +4,8 @@ donated=
|
|||||||
name="User Ten"
|
name="User Ten"
|
||||||
email="user.ten@gmail.com"
|
email="user.ten@gmail.com"
|
||||||
message="ssh-ed25519 AAAAC3NzaC1lAILmSludIBvFRhkxldn1OEgnQdrNd7PxMQjm2DyYCqHjy super-special-key"
|
message="ssh-ed25519 AAAAC3NzaC1lAILmSludIBvFRhkxldn1OEgnQdrNd7PxMQjm2DyYCqHjy super-special-key"
|
||||||
|
switch="uplink_vlan421"
|
||||||
|
ip="46.23.92.101"
|
||||||
hostname="vmten"
|
hostname="vmten"
|
||||||
username="userten"
|
username="userten"
|
||||||
note="This is all awesome!!"
|
note="This is all awesome!!"
|
||||||
|
Loading…
Reference in New Issue
Block a user