Update qmcreate.sh
This commit is contained in:
14
qmcreate.sh
14
qmcreate.sh
@@ -1,13 +1,9 @@
|
||||
#!/bin/bash
|
||||
while read line
|
||||
do
|
||||
#echo $line
|
||||
ip=$(echo $line | cut -d ' ' -f 1)
|
||||
#echo "IP address: $ip"
|
||||
hostname=$(echo $line | cut -d ' ' -f 2)
|
||||
#echo "Hostname: $hostname"
|
||||
vmnum=35$(echo $ip | cut -d '.' -f 4)
|
||||
#echo "VM number: $vmnum"
|
||||
qm clone 5000 $vmnum --name $hostname --full
|
||||
if [ $? -eq 0 ]
|
||||
then echo "clone OK"
|
||||
@@ -16,22 +12,14 @@ 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
|
||||
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
|
||||
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" --sshkey ./gfx.pub
|
||||
qm set $vmnum --cicustom "user=syno-tigra:snippets/${vmnum}_user.yaml"
|
||||
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
|
||||
done < ./hosts
|
||||
Reference in New Issue
Block a user