{"id":64,"date":"2010-02-26T12:04:31","date_gmt":"2010-02-26T17:04:31","guid":{"rendered":"http:\/\/blogs.wp.stage.cpanel.net\/2010\/02\/creating_a_cpanel_auto-installer_iso\/"},"modified":"2010-02-26T12:04:31","modified_gmt":"2010-02-26T17:04:31","slug":"creating_a_cpanel_auto-installer_iso","status":"publish","type":"post","link":"https:\/\/devel.www.cpanel.net\/blog\/products\/creating_a_cpanel_auto-installer_iso\/","title":{"rendered":"Creating a cPanel auto-installer ISO"},"content":{"rendered":"
Over the past few weeks I have been working on a custom spin of the CentOS installation image that automatically installs cPanel. \u00a0This ISO also performs some pre-installation configuration and installs updated packages as well as installing cpanel. \u00a0I think this information is handy for anyone who wants to create a CentOS installation image, whether for cPanel or for something else. \u00a0To create the installation image, we will modify the CentOS installation DVD; adding in a kickstart file, removing unneeded packages, and updating the remaining packages.<\/p>\n
What you need<\/strong> Creating the package list<\/strong> This command generates a file that contains the names of the packages on the system excluding the cPanel-installed packages and a couple of other packages.<\/p>\n Copying the ISO<\/strong> Creating an populating the repository<\/strong> The first step is to clear out the current repository: After the repo has been cleared, we need to repopulate the repo with the updated packages. \u00a0To do so, we will use the yumdownloader utility available within the yum-utils rpm. This will download the latest version of the packages in question from yum and place them in the current directory.<\/p>\n Note: \u00a0This process can take awhile depending on your Internet connection and the speed of the mirror in question.<\/p>\n Once this has been done, we have to populate the repodata files with the correct information. \u00a0This is handled via the createrepo utility: Placing the kickstart file<\/strong> Configuring the Installer to use the kickstart file<\/strong> This file it should currently contain something similar to: On both of these, ks=cpanel-ks.cfg should be added to the end of the append line. \u00a0This will tell the installer to automatically load the kickstart file.<\/p>\n Creating the ISO<\/strong> At this point you can burn the ISO to a disc and begin provisioning your server.<\/p>\n","protected":false},"excerpt":{"rendered":" Over the past few weeks I have been working on a custom spin of the CentOS installation image that automatically installs cPanel. \u00a0This ISO also performs some pre-installation configuration and installs updated packages as well as installing cpanel. \u00a0I think this information is handy for anyone who wants to create a CentOS installation image, whether […]<\/p>\n","protected":false},"author":77,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[49],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-products"],"acf":[],"yoast_head":"\n
\nFor creating this image you will need a few things:<\/p>\n\n
\nyum install -y yum-utils createrepo<\/code><\/li>\n
\nYou will need to grab a list of packages from the cPanel server. \u00a0These are used at several points of the process to let the installer know what it needs to install, \u00a0while letting yumdownloader know what it needs to download. \u00a0Unfortunately, there isn\u2019t an easy way to grab a list of packages that can be used directly. \u00a0Also, cPanel provides some packages that are not available within yum. \u00a0You should never install these manually. \u00a0We will need to filter these packages out. \u00a0You can accomplish this using the following (silly) shell command:
\nrpm -qa | egrep -v \"(nsd|bandmin|proftpd|pure-ftpd|frontpage|gpg-pubkey|MySQL|exim|courier|dovecot)\" | perl -lane '$F[0] =~ s\/-[0-9].+$\/\/; print $F[0];' | sort | uniq > ~\/rpmlist<\/code><\/p>\n
\nCopying the installer ISO is a relatively simple task. \u00a0You simply need to copy it to the system in question, mount it, then copy it to your home directory. \u00a0There are a couple of dot files that need to be copied as well.
\nwget http:\/\/url\/to\/some\/iso
\nmkdir \/mnt\/iso
\nmount -o loop some_iso \/mnt\/iso
\ncp -pr \/mnt\/iso ~
\ncp -pr \/mnt\/iso\/.discinfo ~\/iso\/
\ncp -pr \/mnt\/iso\/.treeinfo ~\/iso\/
\n<\/code><\/p>\n
\nCreating your repository is a very important step to this process. \u00a0Using the packages provided with the DVD will result in an out-of-date installation. \u00a0While this is fine for some uses, you will likely prefer that the installation process installs updated packages. This results in faster installation times.<\/p>\n
\nchdir ~\/iso\/CentOS\/
\nrm -f *<\/code><\/p>\n
\ncd ~\/iso\/CentOS\/<\/em>
\nyumdownloader --resolve `cat ~\/rpmlist | tr \u2018n\u2019 \u2018 \u2018`<\/em><\/code><\/p>\n
\ncd ~\/iso\/
\ncreaterepo -g repodata\/comps.xml .<\/code><\/p>\n
\nYou also need to create and place a kickstart file in the appropriate location. \u00a0You can find an example of this file at http:\/\/httpupdate.cpanel.net\/cpanel-ks.cfg. \u00a0This file can be used for setting defaults, fully automating the installation process, and pre-configuring cPanel. \u00a0In a later post I\u2019ll talk about what can be done with kickstart files for provisioning cPanel servers (documentation can be viewed at http:\/\/www.centos.org\/docs\/5\/html\/Installation_Guide-en-US\/s1-kickstart2-options.html). \u00a0At this point, the only thing you need to know is that you should copy the contents of \/root\/rpmlist and paste them between %packages and %post inside of cpanel-ks.cfg. \u00a0Once this has been done, you should place it in the user\u2019s home directory.
\ncd ~\/iso\/
\nwget http:\/\/httpupdate.cpanel.net\/cpanel-ks.cfg
\n<\/code><\/p>\n
\nThe bootloader will have to be told to use the kickstart file. \u00a0You can accomplish this by editting ~\/iso\/isolinux\/isolinux.cfg.<\/p>\n
\n label linux
\n\u00a0\u00a0kernel vmlinuz
\n\u00a0\u00a0append initrd=initrd.img
\n label text
\n\u00a0\u00a0kernel vmlinuz
\n\u00a0\u00a0append initrd=initrd.img text<\/code><\/p>\n
\nOnce this has been done the \u2018mkisofs\u2019 utility can be used to create the ISO:
\nmkisofs -o $output_file -b isolinux\/isolinux.bin -c isolinux\/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T .<\/code><\/p>\n