Update qmcreate.sh

This commit is contained in:
2025-10-22 14:40:21 +00:00
parent d28e7dc0e4
commit 2ae5c2a161

View File

@@ -16,21 +16,22 @@ do
qm set $vmnum --tags 3,gfx
## preparing custom CloudInit snippets
cp ./user.yaml /mnt/pve/syno-tigra/snippets/${vmnum}_user.yaml
cp ./network.yaml /mnt/pve/syno-tigra/snippets/${vmnum}_network.yaml
#cp ./network.yaml /mnt/pve/syno-tigra/snippets/${vmnum}_network.yaml
sed -i "s/HOSTNAME/$hostname/g" /mnt/pve/syno-tigra/snippets/${vmnum}_user.yaml
sed -i "s/IP/$ip/g" /mnt/pve/syno-tigra/snippets/${vmnum}_network.yaml
mac=$(cat /etc/pve/qemu-server/${vmnum}.conf | grep net0 | cut -d ',' -f 1 | cut -d '=' -f 2)
sed -i "s/MAC/$mac/g" /mnt/pve/syno-tigra/snippets/${vmnum}_network.yaml
#sed -i "s/IP/$ip/g" /mnt/pve/syno-tigra/snippets/${vmnum}_network.yaml
#mac=$(cat /etc/pve/qemu-server/${vmnum}.conf | grep net0 | cut -d ',' -f 1 | cut -d '=' -f 2)
#sed -i "s/MAC/$mac/g" /mnt/pve/syno-tigra/snippets/${vmnum}_network.yaml
if [ -e "./gfx.pub" ]
then echo "key OK"
else echo "key ERROR. Put the public key named 'gfx.pub'"; exit 2
fi
qm resize $vmnum scsi0 +50G
qm set $vmnum --cicustom "user=syno-tigra:snippets/${vmnum}_user.yaml,network=syno-tigra:snippets/${vmnum}_network.yaml" --sshkey ./gfx.pub
qm set $vmnum --cicustom "user=syno-tigra:snippets/${vmnum}_user.yaml" --sshkey ./gfx.pub
qm set $vmnum --ipconfig0 ip=$ip/24,gw=10.10.35.1
qm cloudinit update $vmnum
qm start $vmnum
if [ $? -eq 0 ]
then echo "VM successfully CREATED"
else "ERROR creating VM"; exit 3
fi
#if [ $? -eq 0 ]
# then echo "VM successfully CREATED"
# else "ERROR creating VM"; exit 3
# fi
done < ./hosts