The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need more infos on how to create a custom cpaddon

Discussion in 'cPanel Developers' started by ctrlogic, Apr 25, 2009.

  1. ctrlogic

    ctrlogic Member

    Joined:
    Nov 4, 2008
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Hi I need more infos on how to be able to create a custom cpaddon that's going to take care of website content management...

    Just want to know how to install it, so that users can find it in their cpanel... not the script itself...
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You can find documentation on how to build a cPAddon wrapper for your script at: http://www.cpanel.net/developer/cpaddons/Creating_Addon_Scripts.htm

    While the wrapper must be coded in Perl, the script can be in any programming language (PHP, Ruby, Perl etc.)
     
  3. LP-Trel

    LP-Trel Well-Known Member

    Joined:
    Oct 13, 2003
    Messages:
    184
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Nirvana
    Hi David,

    Has cPanel looked into implementing more advanced functionality into the cPAddons system? The current system seems significantly more limited than the older addons system that I built the Open Installer on.

    The older system allowed for a high degree of flexibility by implementing an installer using a Perl script which allowed us to use almost any function available in Perl. The current system does not allow for that flexibility and that makes more advanced installers harder or impossible to make.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    The cPAddon wrapper is built in Perl so you can use Perl code in there how you desire. You may notice that our install functions are short, because they're just calling some standard code we use for installing apps. However, you can put any Perl code in there that you need.

    Are there any specific things you feel are limiting you from doing what you need to do via cPAddons?
     
  5. LP-Trel

    LP-Trel Well-Known Member

    Joined:
    Oct 13, 2003
    Messages:
    184
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Nirvana
    Hi David,

    Thank you for your reply.

    The documentation you linked to doesn't seem to show the method of using this type of functionality.

    How would one go about running a command such as:

    system("cp","-f","\*.php","install/location/");

    using the new cPAddons installers?
     
  6. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    3
    Trophy Points:
    18
    I think you're misunderstanding how it works, let me explain:

    Instead of a script there are now functions. You can put any code you want in them.

    The "flexibility" and "advanced" part comes from the fact that the logic that 99% of scripts need to get installed is already done and all you have to do is have a hash that describes the script...

    For example, instead of copying files around you just have your tarball exist. No need to know where it will be installed or where you are at at the time or that the appropriate "no same owner flag" for the OS's tar is used.

    You can of course implement the same logic in the install function yourself but it'd be counter productive to do so.

    Now if the standard install does not fit the needs of a script you can have other code before or after it or not even call stdinstall() in the package's install function and implement all of the logic yourself.

    Perhaps there are parts of the documentation that could be made clearer?
     
  7. cPDan

    cPDan cPanel Staff
    Staff Member

    Joined:
    Mar 9, 2004
    Messages:
    711
    Likes Received:
    3
    Trophy Points:
    18
    You just did it :)

    change:

    Code:
    sub install {
        my ($cpa) = @_;
        $cpa->stdinstall(@_);
    }
    to:

    Code:
    sub install {
        my ($cpa) = @_;
        $cpa->stdinstall(@_);
        system(@post_install_cmd);
        return 1; # system() returns 0 on success (i.e. $?)
    }
    For the specific cp command though, you're probably better off doing the tarball correctly, then it's completely moot
     
Loading...

Share This Page