首页 > 代码库 > 脚本练习
脚本练习
#!/bin/bash
case "$1" in
start)
virsh start $2
virt-viewer $2
;;
stop)
virsh destroy $2
;;
install)
yum install $2 -y
;;
reset)
rm -fr /var/lib/libvirt/images/$2.qcow2
qemu-img creat -f qcow2 -b /var/lib/libvirt/images/$3.qcow2 /var/lib/libvirt/images/$2.qcow2
virsh start $2
;;
remove)
yum remove $2
;;
mksnapshoot)
virsh destroy $2
virsh undefine $2
qemu-img creat -f qcow2 -b /var/lib/libvirt/images/$3.qcow2 /var/lib/libvirt/images/$2.qcow2
;;
*)
echo "ERROR:please input start|stop|install|remove|reset|mksnapshoot after command"
esac
脚本练习