Created
February 13, 2013 12:14
-
-
Save pixie79/4944196 to your computer and use it in GitHub Desktop.
OpenVZ: Conversion of a OEL/CentOS virtual server to a Package template cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The raw copy of the virtual server should be extracted to /vz/private/$CTID from there it can be customised using thi script to get it ready for packaging as an openvz tempalte. | |
CTID=101 | |
export CTID | |
echo "none /dev/pts devpts rw 0 0" > /vz/private/$CTID/etc/fstab | |
echo "proc /proc proc defaults 0 0" >> /vz/private/$CTID/etc/fstab | |
echo "tmpfs /dev/shm tmpfs defaults 0 0" >> /vz/private/$CTID/etc/fstab | |
mkdir /vz/private/$CTID/dev | |
mkdir /vz/private/$CTID/mnt | |
mkdir /vz/private/$CTID/proc | |
mkdir /vz/private/$CTID/sys | |
mkdir /vz/private/$CTID/tmp | |
chmod 1777 /vz/private/$CTID/tmp | |
mkdir /vz/private/$CTID/etc/udev/devices | |
/sbin/MAKEDEV -d /vz/private/$CTID/dev {p,t}ty{a,p}{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f} console core full kmem kmsg mem null port ptmx random urandom zero ram0 | |
/sbin/MAKEDEV -d /vz/private/$CTID/etc/udev/devices {p,t}ty{a,p}{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f} console core full kmem kmsg mem null port ptmx random urandom zero ram0 | |
sed -i -e 's/ONBOOT="yes"/ONBOOT="no"/g' /vz/private/$CTID/etc/sysconfig/network-scripts/ifcfg-eth* | |
sed -i -e 's/^\(HWADDR=.*\)$//g' /vz/private/$CTID/etc/sysconfig/network-scripts/ifcfg-eth* | |
sed -i -e 's/^\(UUID=.*\)$//g' /vz/private/$CTID/etc/sysconfig/network-scripts/ifcfg-eth* | |
sed -i -e 's/PROMPT=yes/PROMPT=no/g' /vz/private/$CTID/etc/sysconfig/init | |
sed -i -e 's/^\(console.*\)$/#\1/g' /vz/private/$CTID/etc/init/rc.conf | |
rm -f /vz/private/$CTID/etc/mtab | |
ln -s /proc/mounts /vz/private/$CTID/etc/mtab | |
rm -f /vz/private/$CTID/etc/init/tty.conf | |
rm -f /vz/private/$CTID/etc/init/start-ttys.conf | |
rm -f /vz/private/$CTID/etc/udev/rules.d/70-persistent-net.rules | |
rm -f /vz/private/$CTID/etc/ssh/ssh_host_* | |
cd /vz/private/$CTID | |
tar --numeric-owner -zcf /vz/template/cache/oel-6.3-purpose-i686.tar.gz . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment