vim编辑以.sh结尾的文件
#!/bin/bash
case "$1" in
start)
virsh start $2 &>/dev/null
virt-viewer $2 $>/dev/null
;;
stop)
virsh destroy $2
;;
install)
virt-install \
--name $2 \
--ram 1024 \
--file/var/lib/libvirt/images/$2.qcow2 \
--file-size 8 \
--extra-args"ks=http://172.25.254.70/chen.cfg" &
;;
mksnapshot)
virsh destroy $2
mv/var/lib/libvirt/images/$2.qcow2 /var/lib/libvirt/images/$2.qcow2.chen
qemu-image create -f qcow2 -b/var/lib/libvirt/images/$2.qcow2.chen /var/lib/libvirt/images/$2.qcow2
virsh start $2
virt-viewer $2
;;
reset)
virsh destroy $2
rm -rf/var/lib/libvirt/images/$2.qcow2
qemu-img create -f qcow2 -b/var/lib/libvirt/images/$2.qcow2.chen /var/lib/libvirt/images/$2.qcow2
virsh start $2
virt-viewer $2
;;
remove)
virsh destroy $2
rm -rf/var/lib/libvirt/images/$2.qcow2 /var/lib/libvirt/images/$2.qcow2.chen
;;
*)
echo "ERROR:Can't findyour Action please input start/stop/install/reset/mksnapshot/remove aftercommand"
;;
esac