OpenVZ 7 – 容器创建脚本
kevin.Zhu 发布于:2017-9-23 8:51 分类:Linux 有 25 人浏览,获得评论 0 条
http://www.tomvanbrienen.nl/openvz-7-create-container-script/
#!/bin/bash
clear
echo "This is a script to create OpenVZ containers from commandline";
read -p "Enter container Name: " con ;
echo "IP Address example: 192.168.0.10"
read -p "Enter container IP Address: " ip ;
echo "DNS example (Google): 8.8.8.8"
read -p "Enter container DNS Server: " dns ;
echo "Dedicated RAM example: 4G"
read -p "Enter container Dedicated RAM: " dram ;
echo "Burstable RAM example: 512M"
read -p "Enter container Burstable RAM: " bram ;
echo "Disk Space example: 40G"
read -p "Enter container Disk Space (GB): " disk ;
echo "OS Template List:"
vzpkg list -O
read -p "Enter container OS Template: " os ;
read -p "Enter root Password: " rpass ;
echo "Creating container now.. Please wait.";
##This is the part that creates the container
prlctl create ${con} --vmtype ct --ostemplate ${os}
prlctl set ${con} --hostname ${con} --userpasswd root:${rpass}
prlctl set ${con} --ipadd ${ip} --nameserver ${dns}
prlctl set ${con} --memsize ${dram} --swappages ${bram}
prlctl set ${con} --diskspace ${disk}
prlctl start ${con}
clear
echo "**********VPS successfully created**********"
echo "Container Name and Hostname: ${con}"
echo "DNS Server: ${dns}"
echo "IP Address: ${ip}"
echo "Dedicated RAM: ${dram}"
echo "Burstable RAM: ${bram}"
echo "Disk Space: ${disk}"
echo "OS Template: ${os}"
echo "Root Password: ${rpass}"
echo "********************************************"
echo ""
echo "Source: tomvanbrienen.nl"