This bash script is useful to create Centos or other new VPS in few seconds. You can download it cr_vm.
Source below:
#!/bin/bash
if [ -z "$2" ]; then
echo usage: $0 ctid ipaddr
echo example: 521 192.168.122.152
exit
fi
if [ -f /vz/template/cache/centos-6-x86_64-20130522.tar.xz ]; then
echo "OK"
else
echo "================================================================"
echo "Download a Centos (6.0) template"
echo "================================================================"
wget http://mirror.duomenucentras.lt/openvz/contrib/template/precreated/centos-6-x86_64-20130522.tar.xz -O /vz/template/cache/centos-6-x86_64-20130522.tar.xz
fi
echo "================================================================"
echo "Create a new container named $1"
echo "================================================================"
vzctl create $1 --ostemplate centos-6-x86_64-20130522
echo "================================================================"
echo "Set the hostname"
echo "================================================================"
vzctl set $1 --hostname $1 --save
echo "================================================================"
echo "Set the IP address"
echo "================================================================"
vzctl set $1 --ipadd $2 --save
echo "================================================================"
echo "Set OpenDNS servers 208.67.222.222 and 208.67.220.220"
echo "================================================================"
vzctl set $1 --nameserver 208.67.222.222 --nameserver 208.67.220.220 --save
echo "================================================================"
echo "Set ROOT user password"
echo "================================================================"
vzctl set $1 --userpasswd root:plainpass
echo "================================================================"
echo "Stop and start the container named $1 and wait 10 secs"
echo "================================================================"
vzctl stop $1 && vzctl start $1 && sleep 10
echo "================================================================"
echo "Ping test to google.com"
echo "================================================================"
vzctl exec $1 ping -c 3 google.com
echo "================================================================"
echo "Restarting the node $1"
echo "================================================================"
vzctl restart $1
echo "================================================================"
echo "Test command 'ps aux' executed in the node $1"
echo "================================================================"
vzctl exec $1 ps aux
You can edit this script for your needs.