From d6a56af9e99da86203505994e33202487e9aee40 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Tue, 17 Jun 2014 23:06:09 +0100 Subject: [PATCH] add a script that will generate an image using installroot method --- openvz/create-yum-openvz-7.sh | 102 ++++++++++++++++++++++++++++++++++ openvz/openvz-7.ks | 29 +++------- 2 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 openvz/create-yum-openvz-7.sh diff --git a/openvz/create-yum-openvz-7.sh b/openvz/create-yum-openvz-7.sh new file mode 100644 index 0000000..b503894 --- /dev/null +++ b/openvz/create-yum-openvz-7.sh @@ -0,0 +1,102 @@ +# To get a package list without version numbers from a target system +# rpm -qa --qf "%{n} " > packages.txt +# Put contents of packages.txt after "-y install \" line below + +installroot="/ostemplate" +mount="$(mktemp -d --tmpdir)" +tmpyumconf=$mount/yum.conf + +cat > $tmpyumconf << __YUMCONF__ +[centos7] +name=centos 7 x86_64 +baseurl=http://buildlogs.centos.org/centos/7/os/x86_64-20140614/ +enabled=0 +gpgcheck=0 +__YUMCONF__ + +yum \ +--installroot $installroot \ +-c $tmpyumconf \ +-y install \ + openssh-clients \ + openssh-server \ + yum \ + yum-utils \ + man \ + wget \ + sudo \ + tar \ + passwd + +# Remove firmware files if installed +chroot $installroot rpm -e + aic94xx-firmware \ + alsa-firmware \ + alsa-tools-firmware \ + cronie \ + efibootmgr \ + ethtool \ + iproute \ + iptables \ + iputils \ + ivtv-firmware \ + iwl100-firmware \ + iwl105-firmware \ + iwl135-firmware \ + iwl1000-firmware \ + iwl2000-firmware \ + iwl2030-firmware \ + iwl3160-firmware \ + iwl3945-firmware \ + iwl4965-firmware \ + iwl5000-firmware \ + iwl5150-firmware \ + iwl6000-firmware \ + iwl6000g2a-firmware \ + iwl6000g2b-firmware \ + iwl6050-firmware \ + iwl7260-firmware \ + kbd \ + libertas-sd8686-firmware \ + libertas-sd8787-firmware \ + libertas-usb8388-firmware \ + libertas-usb8388-olpc-firmware \ + linux-firmware \ + postfix \ + policycoreutils \ + selinux-policy \ + selinux-policy-targeted \ + sudo \ + upstart \ + vim-minimal \ + xorg-x11-drv-ati-firmware \ + zd1211-firmware + +# Clean te yum configuration +yum --installroot=$installroot -c $tmpyumconf clean all + +# Remove unnessary files from the build +chroot $installroot rpm -e grub2 grub2-tools grubby centos-logos plymouth plymouth-scripts +chroot $installroot rpm -e initscripts kernel + +# Remove /boot, as that is not required +chroot $installroot rm -rf /boot + +# Create fstab file, which is required for VZ installtions +cat > $installroot/etc/fstab << __FSTAB__ +none /dev/pts devpts rw,gid=5,mode=620 0 0 +none /dev/shm tmpfs defaults 0 0 +__FSTAB__ + +# GMT to be default, but change for requirement +chroot $installroot ln -sf /usr/share/zoneinfo/GMT /etc/localtime + +# Misc post stuff for VZ +ln -s /proc/mounts $installroot/etc/mtab +rm -f $installroot/dev/null +mknod -m 600 $installroot/dev/console c 5 1 + +# Now compress the image +cd $installroot; tar -cvzf /root/centos-7-x86_64-viayum.tar.gz . ; cd +ls -lh /root/centos-7-x86_64-viayum.tar.gz +echo "Done building OS Template. Now test it." diff --git a/openvz/openvz-7.ks b/openvz/openvz-7.ks index 2df1fef..c7180a7 100644 --- a/openvz/openvz-7.ks +++ b/openvz/openvz-7.ks @@ -20,7 +20,15 @@ clearpart --all --initlabel part / --fstype ext4 --size=1024 --grow reboot %packages --excludedocs --nobase -@Core +openssh-clients +openssh-server +yum +yum-utils +man +wget +sudo +tar +passwd -aic94xx-firmware -alsa-firmware -alsa-tools-firmware @@ -64,25 +72,9 @@ reboot -vim-minimal -xorg-x11-drv-ati-firmware -zd1211-firmware -openssh-clients -openssh-server -yum -yum-utils -man -wget -sudo -tar -passwd %end %post -# randomize root password and lock root account -dd if=/dev/urandom count=50 | md5sum | passwd --stdin root -passwd -l root - -# create necessary devices -/sbin/MAKEDEV /dev/console - # cleanup unwanted stuff # ami-creator requires grub during the install, so we remove it (and @@ -130,7 +122,4 @@ __FSTAB__ # Timezone cp -f /usr/share/zoneinfo/GMT /etc/localtime -# Update the CONSOLEs for the image -sed -i -e 's/^\(ACTIVE_CONSOLES=\).*/\1//g' /etc/sysconfig/init - %end