IF脚本实现虚拟机的开启,关闭,重置,快照

来源:互联网 发布:mac os x10.7.5升级包 编辑:程序博客网 时间:2024/06/14 02:13

需注意:不能随便给末尾加空格

#!/bin/bashif    [ "$1" = "install" ]then    virt-install \    --name $2 \    --ram 1024 \    --file /var/lib/libvirt/images/$2.qcow2 \    --file-size 8 \    --cdrom /iso/rhel-server-7.0-x86_64-dvd.iso & elif        [ "$1" = "start" ] then        virsh start $2        virt-viewer $2elif        [ "$1" = "stop" ]then        virsh destroy $2elif        [ "$1" = "mksnopshot" ]then        virsh destroy $2        virsh undefine $2        qemu-img create -f qcow2 -b /var/lib/libvirt/images/$2.qcow2 /var/lib/libvirt/images/$3.qcow2         virt-install \         --name $3 \        --ram 1024 \        --file /var/lib/libvirt/images/$3.qcow2 \        --import &elif      [ "$1" = "reset" ]then     virsh reset $2elif     [ "$1" = "remove" ]then    virsh destroy $2    virsh undefine $2    rm -fr /var/lib/libvirt/images/$2.qcow2 /var/li    b/libvirt/images/$3.qcow2fi

“`

0 0
原创粉丝点击