diff --git a/capsulflask/shell_scripts/create.sh b/capsulflask/shell_scripts/create.sh index 9ae1ebf..1c74cbc 100755 --- a/capsulflask/shell_scripts/create.sh +++ b/capsulflask/shell_scripts/create.sh @@ -9,6 +9,8 @@ template_file="/tank/img/$2" vcpus="$3" memory="$4" pubkeys="$5" +network_name="$6" +public_ipv4="$7" root_volume_size="25G" if echo "$vmname" | grep -vqE '^capsul-[a-z0-9]{10}$'; then @@ -38,6 +40,16 @@ echo "$pubkeys" | while IFS= read -r line; do fi done +if echo "$network_name" | grep -vqE "^[a-zA-Z0-9_-]+"; then + echo "network_name \"$network_name\" must match ^[a-zA-Z0-9_-]+" + exit 1 +fi + +if echo "$public_ipv4" | grep -vqE "^[0-9.]+$"; then + echo "public_ipv4 \"$public_ipv4\" must match ^[0-9.]+$" + exit 1 +fi + disk="/tank/vm/$vmname.qcow2" cdrom="/tank/vm/$vmname.iso" xml="/tank/vm/$vmname.xml" @@ -66,7 +78,7 @@ virt-install \ --os-variant generic \ --virt-type kvm \ --graphics vnc,listen=127.0.0.1 \ - --network network=public3,filterref=clean-traffic,model=virtio \ + --network network=$network_name,filterref=clean-traffic,model=virtio \ --import \ --print-xml > "$xml"