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.

cPanel Plugin Update Error

Discussion in 'cPanel Developers' started by varunms, Jan 21, 2013.

  1. varunms

    varunms Active Member

    Joined:
    Aug 29, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    INDIA
    cPanel Access Level:
    Root Administrator
    Hi

    i have developed 2 plugin called

    1) cPanel Login Email Alert
    2) cPanel Resource Monitor

    While installing this plugin it will edit index.html in /usr/local/cpanel/base/frontend/x3

    and if i update the cPanel the edited version of index.html is getting replaced by new one and the plugin is now working

    what to do ?
     
  2. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    It appears that you also submitted a ticket with the same question.

    Do not edit a cPanel theme directly. cPanel themes will be overwritten every time cPanel updates. Instead, clone the theme and edit the cloned theme.

    You can clone a theme in the WebHost Manager in Home » Themes » Universal Theme Manager. When you clone a theme, a new directory for the cloned theme will be created in /usr/local/cpanel/base/frontend. Edit the index.html file in that directory, not in the x3 directory.

    You will need to set your accounts to use the cloned theme instead of x3. You can do this in the WHM by clicking either Home » Account Functions » Modify an Account or Home » Multi Account Functions » Modify/Upgrade Multiple Accounts.

    Note that, once you clone a theme and make custom edits to it, you will need to maintain that theme as updates are made to cPanel versions. We sometimes see problems caused by custom themes that have not been kept up to date with the latest versions of cPanel.

    Instead of editing the theme's index.html file, have you looked at registering a cPanel plug-in, which will cause the plug-in's icon to be displayed in cPanel without needing to manually edit the theme? This would really be simpler, with less chance of problems in the future, than what you are trying to do. This is documented here:

    InstallingPlugins < SoftwareDevelopmentKit < TWiki

    The index to our developer documentation is here:

    cPanel & WHM's SDK
     
  3. varunms

    varunms Active Member

    Joined:
    Aug 29, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    INDIA
    cPanel Access Level:
    Root Administrator
    is there any other way because i have already developed the plugin and submitted to cpanel app catalog for all others there will be the same issue.. so what to do ???
     
  4. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Unless you have some update mechanism built into your plugin, you will need to contact your users or post a notice so they can update.

    What are you looking to do with index.html? Are you looking to add icons, add stats? There are hooks you can use to modify the index page programmatically rather than just editing it. However, more information about what you're looking to accomplish will help guide you in the right direction.
     
  5. varunms

    varunms Active Member

    Joined:
    Aug 29, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    INDIA
    cPanel Access Level:
    Root Administrator
    Hi

    i need to add a script tag in index.html file is there any hook ???

    can you help me please .... ?
     
  6. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    You can hook into any of the cPanel API2 functions that are called by index.html. I tend to hook into Branding::applist() as it should be around for a while and is called only once.

    You'll need to read up on the cPanel Standardized hooks system for where to place files and how to activate the hook with your installer:
    Introduction to Standardized Hooks

    Here's sample code for a module hook that would let you add some javascript code to the index.html page on-the-fly:

    Code:
    #!/usr/bin/perl
    
    package ScriptHook;
    
    sub describe {
        my $hooks = {
            'hook'      => 'ScriptHook::applist',
            'function'  => 'Api2::Branding::applist',
            'exectype'  => 'module',
            'namespace' => 'Cpanel',
            'stage'     => 'post'
        };
        return $hooks;
    }
    
    sub applist {
        print <<'EOM';
    		<script type="text/javascript">alert('working');</script>
    EOM
    }
    
    1;
    
     
  7. varunms

    varunms Active Member

    Joined:
    Aug 29, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    INDIA
    cPanel Access Level:
    Root Administrator
    but how i can run this ?
    and i need that code to run automatically after the whm update
     
  8. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    You don't need the code to run after a WHM update. Hooks run when the page is loaded. You just need to install this code as a module hook on the cPanel server and it is good to go.

    You should really read the Standardized Hooks document I posted:

    Introduction to Standardized Hooks
     
  9. varunms

    varunms Active Member

    Joined:
    Aug 29, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    INDIA
    cPanel Access Level:
    Root Administrator
    hi

    sir i really studied that link fully but when i try add i get the error as

    WARNING: No âdescribeâ--manualâ
    The provided script hook is not executable


    can you tell me how i can add that perl script or give me an example please
     
  10. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    manage_hooks should be executed specifying this as a module hook like:

    Code:
    /usr/local/cpanel/bin/manage_hooks add module ScriptHook
    
    That will only work if the file is named ScriptHook.pm and located at /var/cpanel/perl5/lib/ScriptHook.pm

    You can use 'chmod +x /var/cpanel/perl5/lib/ScriptHook.pm' to make it executable.
     
  11. varunms

    varunms Active Member

    Joined:
    Aug 29, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    INDIA
    cPanel Access Level:
    Root Administrator
    Hi,

    where the file need to be located .. ?

    the location u gave me its not working.... /var/cpanel/perl5/lib/
    i get error as no such dir

    and used the below code to add the hook

    ./manage_hooks add script /usr/local/cpanel/base/frontend/x3/cpu_usages/ScriptHook.pm --category=ScriptHook::applist --event=Api2::Branding::applist --stage=post
     
  12. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    You need to create this directory. It will not exist by default.

    You should use the command to add this module. If you wish to add the hook as a script instead of a module, you will need to rewrite it.

    Code:
    /usr/local/cpanel/bin/manage_hooks add module ScriptHook
    

    Here's the page of documentation that covers module hooks in Perl:

    Basic Usage | Standardized Hooks Perl modules
     
Loading...

Share This Page