OpenVZ cache update script
Script to update OpenVZ vz cache for any template.
Useful to upgrade to newest security releases.
#!/bin/bash
#
# updates cache of VZ
#
##
# Set These (or pass from command line as below)
#
#TEMPLATE=centos-5-i386-afull
VZID=5999
#
# use this from command line:
#
# ./updatevzcache centos-5-i386-afull
#
TEMPLATE=$1
# VZID=$2#
# change these if needed
#
HOSTNAME=testvps.zoidial.com
IP=10.10.10.100
NAMESERVER=10.10.10.1#
# create vps, add IP address, set hostname, set nameserver, start vps
#vzctl create $VZID –ostemplate $TEMPLATE –ipadd $IP –hostname $HOSTNAME
vzctl set $VZID –nameserver $NAMESERVER –save
vzctl start $VZID
#vzctl enter $VZID#
# run some update commands on the VPS
#vzctl exec $VZID “yum clean all; yum upgrade -y; yum clean all; > /etc/resolv.conf”
#
# stop vps, delete ip addresses
#vzctl stop $VZID
vzctl set $VZID –ipdel all –save#
# zero out all logs in the vps (we want it to look fresh!)
#for i in `ls -1 /vz/private/$VZID/var/log`; do echo “” > /vz/private/$VZID/var/log/$i; done
for i in `ls -1 /vz/private/$VZID/var/log/*/*`; do echo “” > $i; done#
# move old vps template to a backup
#mv /vz/template/cache/$TEMPLATE.tar.gz{,-old}
#
# Enter vps private directory, make a template from this VPS (nice 19 and ionice to limit impact of this tar)
#cd /vz/private/$VZID
nice -19 ionice -c 2 -n 7 tar czf /vz/template/cache/$TEMPLATE.tar.gz .
chmod +rx /vz/template/cache/$TEMPLATE.tar.gz#
# back to /root dir
#cd /root/
#
# destroy this temporary vps and config
#vzctl destroy $VZID
rm -f /etc/vz/conf/$VZID.conf.destroyed#
# double check that the template looks like it’s been updated
#ls -lh /vz/template/cache/$TEMPLATE*
Categories
- apache (4)
- freebsd (4)
- general (1)
- linux & freebsd (13)
- php (1)
- plesk (3)
- sendmail (2)
- system administration (1)
- uncategorized (1)
- vmware (1)
Topics
apache apache ddos spam apache referrer ddos apache referrer spam awk bash centos cli client_pref cron dell 1650 djpeg freebsd freebsd 6.x gocr grep httpd.conf image text recognition ipmi ipmitool linux linux & freebsd lm_sensors mailscanner mod_rewrite mod_rewrite blocking of spam ntpdate ocr OpenIPMI optical character recognition permission denied php php4 php5 plesk plesk 8.0.x rpm sendmail sort spam spamassassin suspend tesseract time yumLinks
Admin Links





