Update vmcreate.sh
This commit is contained in:
28
vmcreate.sh
28
vmcreate.sh
@@ -1,22 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
for line in $(<hosts)
|
for line in $(cat gfx_hosts)
|
||||||
do
|
do
|
||||||
ip=$(echo $line | cut -d ' ' -f 1)
|
ip=$(echo $line | cut -d ';' -f 1)
|
||||||
hostname=$(echo $line | cut -d ' ' -f 2)
|
hostname=$(echo $line | cut -d ';' -f 2)
|
||||||
vmnum=$(echo $ip | cut -d '.' -f 3,4 | sed 's/\.// ')
|
vmid=$(echo $ip | cut -d '.' -f 3,4 | sed 's/\.// ')
|
||||||
qm clone 5000 $vmnum --name $hostname --full
|
qm clone 5000 $vmid --name $hostname --full
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then echo "clone OK"
|
then echo "clone OK"
|
||||||
else "clone ERROR"; exit 1
|
else "clone ERROR"; exit 1
|
||||||
fi
|
fi
|
||||||
qm set $vmnum --tags 3,gfx
|
qm set $vmid --tags 3,gfx
|
||||||
## preparing custom CloudInit snippets
|
## preparing custom CloudInit snippets
|
||||||
cp ./user.yaml /mnt/pve/syno-tigra/snippets/${vmnum}_user.yaml
|
cp ./user.yaml /mnt/pve/syno-tigra/snippets/${vmid}_user.yaml
|
||||||
sed -i "s/HOSTNAME/$hostname/g" /mnt/pve/syno-tigra/snippets/${vmnum}_user.yaml
|
sed -i "s/HOSTNAME/$hostname/g" /mnt/pve/syno-tigra/snippets/${vmid}_user.yaml
|
||||||
qm resize $vmnum scsi0 +50G
|
qm resize $vmid scsi0 +50G
|
||||||
qm set $vmnum --cicustom "user=syno-tigra:snippets/${vmnum}_user.yaml"
|
qm set $vmid --cicustom "user=syno-tigra:snippets/${vmid}_user.yaml"
|
||||||
qm set $vmnum --ipconfig0 ip=$ip/24,gw=10.10.35.1
|
qm set $vmid --ipconfig0 ip=$ip/24,gw=10.10.35.1
|
||||||
qm cloudinit update $vmnum
|
qm cloudinit update $vmid
|
||||||
qm start $vmnum
|
qm start $vmid
|
||||||
done
|
done
|
||||||
echo "VMs from 'hosts' successfully created"
|
echo "VMs from 'gfx_hosts' successfully created"
|
||||||
Reference in New Issue
Block a user