{"id":63173,"date":"2010-03-03T13:52:34","date_gmt":"2010-03-03T18:52:34","guid":{"rendered":"http:\/\/blogs.wp.stage.cpanel.net\/2010\/03\/cpanel_auto_provisioning_through_kickstart\/"},"modified":"2010-03-03T13:52:34","modified_gmt":"2010-03-03T18:52:34","slug":"cpanel_auto_provisioning_through_kickstart","status":"publish","type":"post","link":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/","title":{"rendered":"cPanel Auto Provisioning through Kickstart"},"content":{"rendered":"

In my last post I talked about how to create the CentOS\/cPanel installer ISO.\u00a0 This information is good, but what if you want to do something more?\u00a0 What if you wanted to pre-configure cPanel? What if you wanted cPanel to automatically use a certain EasyApache profile?<\/p>\n

You can easily accomplish this in a way that can be used with any kickstart-based deployment method, not just the ISO image method.<\/p>\n

Kickstart works by passing a kickstart file to anaconda (the Red Hat\u00ae installer application).\u00a0 This application specifies certain installation options, such as what packages need to be installed, the partitioning layout, etc. Red Hat has documentation on this here<\/a> and CentOS has a nice \u201cTips and Tricks\u201d guide here<\/a>.<\/p>\n

These articles cover how to handle the OS configuration aspect of kickstart. But what about the cPanel configuration? <\/p>\n

Details<\/strong>
\nThe way that cPanel installs inside of the cpanel-ks.cfg file that we provide is by executing a script on first boot if \/var\/cpanel does not exist:<\/p>\n

cat <<EOM >> \/etc\/rc.local
\nif [ ! -d \"\/var\/cpanel\"\u00a0 ]; then
\nnohup \/home\/cpinst\/CDinstaller.sh & > \/dev\/null
\nfi
\nEOM
\n<\/code><\/p>\n

We will make most of our changes to CDinstaller.sh, where it is embedded inside cpanel-ks.cfg<\/a> after %post. This way, we can ensure that installation actions are performed at the correct point (e.g. before or after the cPanel installation).<\/p>\n

Here is a copy of the CDInstaller.sh file that appears within cpanel-ks.cfg<\/a>, with comments to show where you should add the pre- and post-installation actions.
\ncat <<EOM >> \/home\/cpinst\/CDinstaller.sh
\n#!\/bin\/bash
\nfunction messenger {
\necho $1 >> \/dev\/console
\nwall $1
\necho $1 >> \/var\/log\/cpanel-install-autoinstaller.log
\n}
\nif ! nc -z httpupdate.cpanel.net 80 -w 10 > \/dev\/null; then
\nmessenger \"Could not reach httpupdate.cpanel.net, aborting installation. Please resolve this issue and reboot to proceed with installation.\"
\nexit
\nfi
\ntouch \/var\/log\/cpanel-install-thread0.log
\ntouch \/var\/log\/cpanel-install-thread1.log
\nmessenger \"Starting CentOS system update\"
\nyum update -y
\nmessenger \"Finished CentOS system update, starting cPanel installation\"
\ncd \/home\/cpinst
\n## PRE INSTALLATION SECTION
\nwget http:\/\/httpupdate.cpanel.net\/latest
\nmkdir -p \/usr\/local\/cpanel\/logs
\nCPANEL_LOGGER_FILE:\/usr\/local\/cpanel\/logs\/cpanel-install-autoinstaller.log
\nsh latest
\nif [ -d \"\/var\/cpanel\" ]; then
\nmv \/etc\/motd.orig \/etc\/motd
\nmessenger \"cPanel installation Complete\"
\nfi
\n## POST INSTALLATION SECTION
\nEOM<\/code><\/p>\n

Within the CDinstaller.sh file, we have an additional function that we should note:\u00a0 \u201cmessenger\u201d. This function is used for providing status updates to the shell and logs. Anytime an action is added, the messenger function should be used to send a status update.<\/p>\n

Setting your branch<\/strong>
\nThe most basic of tasks would be to add a branch. You can easily accomplish this by echoing the string \u201cCPANEL=$branch\u201d to \/etc\/cpupdate.conf. For example, in the pre-installation section of cpanel-ks.cfg you would add:
\nmessenger \u201cSetting cPanel branch to stable\u201d
\necho \u201cCPANEL=stable\u201d > \/etc\/cpupdate.conf<\/code><\/p>\n

This will make the installer automatically install cPanel\u2019s stable branch.\u00a0 Valid strings for this parameter are: edge, current, release (The default cPanel installation branch) and stable.\u00a0 You can also disable automatic updates by adding \u201c-manual\u201d to the end of this string\u00a0 (e.g. \u201cCPANEL=stable-manual\u201d).<\/p>\n

Configuring cPanel<\/strong>
\ncPanel\u2019s Tweak Settings configuration is handled by \/var\/cpanel\/cpanel.config. This controls options such as which webmail clients are installed, which nameserver and SMTP dameons to use, and memory limits (see: http:\/\/docs.cpanel.net\/twiki\/bin\/view\/AllDocumentation\/InstallationGuide\/AdvancedOptions for more information).\u00a0 To control these settings before installing cPanel, you will need to create the \/root\/cpanel_profile\/cpanel.config file.\u00a0 To view available options, you can look at \/var\/cpanel\/cpanel.config on an existing system.<\/p>\n

There are two logical ways to populate the cpanel.config file:<\/p>\n

One method of setting options within cpanel.config would be to simply echo values into the file:
\nmkdir -p \/root\/cpanel_profile\/
\nmessenger \u201cSetting cPanel to use Courier\u201d
\necho \u201cmailserver=courier\u201d >> \/root\/cpanel_profile\/cpanel.config<\/code><\/p>\n

cpanel.config is portable from system to system as it contains no-system specific information.\u00a0 This means that you can generate cpanel.config on anexisting cPanel server, host it on an accessible web server, and use it with CDinstaller.sh:
\nmessenger \u201cDownloading cPanel Profile\u201d
\nmkdir -p \/root\/cpanel_profile\/
\nwget -O \/root\/cpanel_profile\/cpanel.config http:\/\/somehost\/cpanel.config<\/code><\/p>\n

Warning<\/strong>:\u00a0 It is important to note that the installer is not normally tested with all possible permutations of cpanel.config.\u00a0 Please be aware of this fact and test your configuration before production deployment.<\/p>\n

EasyApache Profiles<\/strong>
\nOne thing that I find annoying about provisioning a cPanel server is having to recompile Apache\/PHP after cPanel has been installed.\u00a0 Luckily, the installer can provide an EasyApache profile so that Apache\/PHP\/etc are built with your desired settings when cPanel is installed.\u00a0 The first step to doing this is that you need to generate an EA3 profile on an existing cPanel server:<\/p>\n

    \n
  1. Log in to WHM.<\/li>\n
  2. Click on EasyApache (Apache Update).<\/li>\n
  3. Click Start Customizing Based on Profile.<\/li>\n
  4. Go through the steps until you reach step 5, and click on Exhaustive options list (at the bottom).<\/li>\n
  5. At the very bottom of the exhaustive options list, you will see Save Selections as Custom Profile. Fill out this information, then click on Save Only (DO NOT BUILD).<\/li>\n
  6. Click on Go back to profile screen.<\/li>\n
  7. Click on More Info next to the profile you created.<\/li>\n
  8. Click on Download profile.<\/li>\n<\/ol>\n

    This will provide you with an EasyApache profile you can use during the installation of your system.\u00a0 At this point in the pre-installation section of CDinstaller.sh, you can use wget to download the \/etc\/cp_easyapache_profile.yaml to your system.<\/p>\n

    messenger \u201cDownloading EA3 Profile\u201d
    \nwget -O \/etc\/cp_easyapache_profile.yaml http:\/\/somehost\/someprofile.yaml
    \n<\/code><\/p>\n

    Installation of Third-Party Software<\/strong>
    \nI know that a lot of our customers use third-party software (this blog *is* about product integration, isn\u2019t it?).\u00a0 When setting up a server, it would be handy to have some software automatically installed.\u00a0 For example, you can automatically have CSF (ConfigServer\u2019s excellent free firewall for cPanel\/WHM) installed by specifying a few extra steps in the %post-installation section:
    \nmessenger \u201cInstalling CSF\u201d
    \nwget http:\/\/www.configserver.com\/free\/csf.tgz
    \ntar vzxf csf.tgz
    \ncd csf
    \n.\/install.cpanel.sh
    \nperl -i -pe 's\/T
    \nESTING = \"1\"\/TESTING = \"0\"\/' \/etc\/csf\/csf.conf
    \ncsf -r
    \ncd -<\/code><\/p>\n

    This will install CSF and disable testing mode automatically (which should be fine on a fresh server).<\/p>\n

    That covers all of the points we will discuss regarding kickstart provisioning in this blog post.\u00a0 In the next post of this series, I will discuss how to automate the Getting Started Wizard in WHM.<\/p>\n","protected":false},"excerpt":{"rendered":"

    In my last post I talked about how to create the CentOS\/cPanel installer ISO.\u00a0 This information is good, but what if you want to do something more?\u00a0 What if you wanted to pre-configure cPanel? What if you wanted cPanel to automatically use a certain EasyApache profile? You can easily accomplish this in a way that […]<\/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":[385],"class_list":["post-63173","post","type-post","status-publish","format-standard","hentry","category-products","tag-provisioning"],"acf":[],"yoast_head":"\ncPanel Auto Provisioning through Kickstart | cPanel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"cPanel Auto Provisioning through Kickstart | cPanel\" \/>\n<meta property=\"og:description\" content=\"In my last post I talked about how to create the CentOS\/cPanel installer ISO.\u00a0 This information is good, but what if you want to do something more?\u00a0 What if you wanted to pre-configure cPanel? What if you wanted cPanel to automatically use a certain EasyApache profile? You can easily accomplish this in a way that […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/\" \/>\n<meta property=\"og:site_name\" content=\"cPanel\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cpanel\/\" \/>\n<meta property=\"article:published_time\" content=\"2010-03-03T18:52:34+00:00\" \/>\n<meta name=\"author\" content=\"cPanel Community\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cPanel\" \/>\n<meta name=\"twitter:site\" content=\"@cPanel\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cPanel Community\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/\",\"url\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/\",\"name\":\"cPanel Auto Provisioning through Kickstart | cPanel\",\"isPartOf\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/#website\"},\"datePublished\":\"2010-03-03T18:52:34+00:00\",\"dateModified\":\"2010-03-03T18:52:34+00:00\",\"author\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8\"},\"breadcrumb\":{\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/devel.www.cpanel.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"cPanel Auto Provisioning through Kickstart\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#website\",\"url\":\"https:\/\/devel.www.cpanel.net\/\",\"name\":\"cPanel\",\"description\":\"Hosting Platform of Choices\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/devel.www.cpanel.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8\",\"name\":\"cPanel Community\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g\",\"caption\":\"cPanel Community\"},\"description\":\"The web hosting industry's most reliable management solution since 1997. With our first-class support and rich feature set, it's easy to see why our customers and partners make cPanel & WHM their hosting platform of choice. For more information, visit cPanel.net.\",\"sameAs\":[\"https:\/\/cpanel.net\"],\"url\":\"https:\/\/devel.www.cpanel.net\/blog\/author\/cpadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"cPanel Auto Provisioning through Kickstart | cPanel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/","og_locale":"en_US","og_type":"article","og_title":"cPanel Auto Provisioning through Kickstart | cPanel","og_description":"In my last post I talked about how to create the CentOS\/cPanel installer ISO.\u00a0 This information is good, but what if you want to do something more?\u00a0 What if you wanted to pre-configure cPanel? What if you wanted cPanel to automatically use a certain EasyApache profile? You can easily accomplish this in a way that […]","og_url":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/","og_site_name":"cPanel","article_publisher":"https:\/\/www.facebook.com\/cpanel\/","article_published_time":"2010-03-03T18:52:34+00:00","author":"cPanel Community","twitter_card":"summary_large_image","twitter_creator":"@cPanel","twitter_site":"@cPanel","twitter_misc":{"Written by":"cPanel Community","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/","url":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/","name":"cPanel Auto Provisioning through Kickstart | cPanel","isPartOf":{"@id":"https:\/\/devel.www.cpanel.net\/#website"},"datePublished":"2010-03-03T18:52:34+00:00","dateModified":"2010-03-03T18:52:34+00:00","author":{"@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8"},"breadcrumb":{"@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/devel.www.cpanel.net\/blog\/products\/cpanel_auto_provisioning_through_kickstart\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/devel.www.cpanel.net\/"},{"@type":"ListItem","position":2,"name":"cPanel Auto Provisioning through Kickstart"}]},{"@type":"WebSite","@id":"https:\/\/devel.www.cpanel.net\/#website","url":"https:\/\/devel.www.cpanel.net\/","name":"cPanel","description":"Hosting Platform of Choices","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/devel.www.cpanel.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/8cf97408aad4fb70cf55d11a1d4f57f8","name":"cPanel Community","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/devel.www.cpanel.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e1949945083b5526bb95711bd3d616b3?s=96&d=mm&r=g","caption":"cPanel Community"},"description":"The web hosting industry's most reliable management solution since 1997. With our first-class support and rich feature set, it's easy to see why our customers and partners make cPanel & WHM their hosting platform of choice. For more information, visit cPanel.net.","sameAs":["https:\/\/cpanel.net"],"url":"https:\/\/devel.www.cpanel.net\/blog\/author\/cpadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts\/63173"}],"collection":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/comments?post=63173"}],"version-history":[{"count":0,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/posts\/63173\/revisions"}],"wp:attachment":[{"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/media?parent=63173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/categories?post=63173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devel.www.cpanel.net\/wp-json\/wp\/v2\/tags?post=63173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}