master
root 2 years ago
parent 283ba01689
commit cf58a12615
  1. 2
      control/VMHost.sh

@ -111,6 +111,7 @@ if [ ! -d ${MOUNT_PATH} ];then
mkdir -p ${MOUNT_PATH} mkdir -p ${MOUNT_PATH}
fi fi
qemu-img create -f qcow2 -b ${TEMPLATE_PATH}/${TEMPLATE_IMAGE_NAME} ${VDISKS_PATH}/${VM_HOSTNAME}.qcow2 qemu-img create -f qcow2 -b ${TEMPLATE_PATH}/${TEMPLATE_IMAGE_NAME} ${VDISKS_PATH}/${VM_HOSTNAME}.qcow2
rm -rf ${MOUNT_PATH}/*
guestmount -a ${VDISKS_PATH}/${VM_HOSTNAME}.qcow2 -m /dev/centos/root ${MOUNT_PATH} guestmount -a ${VDISKS_PATH}/${VM_HOSTNAME}.qcow2 -m /dev/centos/root ${MOUNT_PATH}
/usr/bin/cp -f ${TEMPLATE_PATH}/${TEMPLATE_NETWORK_NAME} ${MOUNT_PATH}/etc/sysconfig/network-scripts/ifcfg-eth0 /usr/bin/cp -f ${TEMPLATE_PATH}/${TEMPLATE_NETWORK_NAME} ${MOUNT_PATH}/etc/sysconfig/network-scripts/ifcfg-eth0
sed -ri "s/^IPADDR.*/IPADDR=${KVM_ADDRESS}/" ${MOUNT_PATH}/etc/sysconfig/network-scripts/ifcfg-eth0 sed -ri "s/^IPADDR.*/IPADDR=${KVM_ADDRESS}/" ${MOUNT_PATH}/etc/sysconfig/network-scripts/ifcfg-eth0
@ -119,7 +120,6 @@ sed -ri "s/.*/${VM_HOSTNAME}/" ${MOUNT_PATH}/etc/hostname
cp ${TEMPLATE_PATH}/${TEMPLATE_REGISTER_NAME} ${MOUNT_PATH}/opt && \ cp ${TEMPLATE_PATH}/${TEMPLATE_REGISTER_NAME} ${MOUNT_PATH}/opt && \
echo "python3 /opt/${TEMPLATE_REGISTER_NAME}" ${VM_HOSTNAME} >> ${MOUNT_PATH}/etc/rc.d/rc.local && \ echo "python3 /opt/${TEMPLATE_REGISTER_NAME}" ${VM_HOSTNAME} >> ${MOUNT_PATH}/etc/rc.d/rc.local && \
chmod a+x ${MOUNT_PATH}/etc/rc.d/rc.local chmod a+x ${MOUNT_PATH}/etc/rc.d/rc.local
rm -rf ${MOUNT_PATH}/*
guestunmount ${MOUNT_PATH} guestunmount ${MOUNT_PATH}
cp ${TEMPLATE_PATH}/${TEMPLATE_CONFIG_NAME} ${CONFIG_PATH}/${VM_HOSTNAME}.xml cp ${TEMPLATE_PATH}/${TEMPLATE_CONFIG_NAME} ${CONFIG_PATH}/${VM_HOSTNAME}.xml

Loading…
Cancel
Save