TMBG_Inc::Category::Name name space using the directions in Creating a New cPAddon Script. The first step is to pick a short descriptive Vendor name that identifies the individual or organization behind him or her. It must be all numbers, letters, and underscores.
To create a Vendor name, use a custom name when creating your addon script. For example: package Vendor::Category::Name; or John::CMS::Johns_Content_System. For more information on creating an addon script, see Basic Sample Module.
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(header param);
print header('text/plain');
my $data = param('cphost') ? 'your.cpsync.host.here'
: param('cphuri') ? '/cpaddons/path/on/cphost/here'
: param('palmd5') ? 'MD5_Sum_of_your_/cPAddonsMd5/Vendor.pm_here'
: 'Your_Vendor_Name_Here'; # must be ^\w+$
print $data;
You will need to change the 4 pieces of data to reflect your hostname, path of the addon, md5 sum of your addon package, and your vendor name.
In that example above, the URL of the base cPAddons directory would be:
http://your.cpsync.host.here/cpaddons/path/on/cphost/here/
The URL will need to point to a server using cPanel Sync, where all files for your vendorship and cPAddons will be located.
Those files would be: cPAddonsAvailable/Vendor.pm
package cPAddonsAvailable::Vendor;
our %list = (
'Vendor::Category::Name' => {
'VERSION' => '0.0.1', # $Vendor::Category::Name::VERSION
'version' =>
'1.0-beta', # script's version, same as $meta_info->{'version'}
},
# repeat for each cPAddon you want to distribute
);
1;
cPAddonsMD5/Vendor.pm (update the md5 sum of this file in "cPAddon Vendor Info Url" when you edit it).
package cPAddonsMD5::Vendor;
our %cpaddons = (
'Vendor::Support::Mars_Rover' => {
'md5' => '024994ae44c700902ced23c777cf25d2', # md5 of .pm file
'desc' => 'This script is a Perl/MySQL based Mars Rover Support system',
},
# repeat for each cPAddon you want to distribute
);
1;
Vendor/*/* — These are the actual cPAddons you create: Vendor/Category/Foo/*
Vendor/Category/Foo.pm
/usr/local/cpanel/cpaddons/Vendor/Category/
This includes your cPAddon.pm and your cPAddon directory.
Add your available and md5 modules to: /usr/local/cpanel/cpaddons/cPAddonsAvailable/Vendor.pm
/usr/local/cpanel/cpaddons/cPAddonsMD5/Vendor.pm
Vendor.pm files is available in our Distributing Your Addons documentation.
Your cPAddons will only show up if the Vendor is in the %vend hash inside /usr/local/cpanel/cpaddons/cPAddonsConf.pm.
The key should be your vendor name. The value should be an empty hashref.
our %vend = (
...
'Vendor' => {},
...
);
$meta_infoLicensing addons key "vendor_license" to install regardless of whether a valid license was entered (ie, your addon script will just detect an invalid license and handle as you wish).
$meta_info key "vendor_license" to install only if the license entered was valid as determined by your license server on the fly.
install_field key called vendor_license as well as a simple check for the license in install_field_hook.
After that:
To simply allow them to enter a ^\w+$ license key and put it in [% vendor_license %]:
'vendor_license' => {},
To allow them to enter a license key of any format you wish and put it in [% vendor_license %]:
'vendor_license' => {
'bad_string_error' => 'Needs to be 32 digits',
#optional description of problem with the
#input as determined by the code ref below
'string_is_ok' => sub {
my($lisc_string) = @_; # 32 digits
return 1 if length $lisc_string == 32 && $lisc_string =~ m/^\d+$/; # ^\d{32}$
return 0;
},
},
To allow them to enter anything they want and have a script verify it is valid or else not install/upgrade it:
'vendor_license' => {
'use_url_as_error' => 1,
#optional, turns on or off using the result of the
#url in the same way as 'bad_string_error' above # it
#would be best to just return short text string
'verify_url' => 'http://foo.bar.baz/lisc.pl', # ?user=cpanel_user
lisc=liscense_string_from_input_here
'url_says_its_ok' => sub {
my ($url_result) = @_; # it is empty if url failed
return 1 if $url_result =~ m/Vendor says Valid/;
return 0;
},
},
cpanelsync_build_cpaddons_dir in the distribution's /scripts directory that you can use to build your cpanelsync/ directory for your cPAddons. You will need to copy it to your server to a location that is not publicly accessible and execute it on your server as root. Then, follow its prompts to see what data you need to supply it so that it can build what you need.
For example: ./cpanelsync_build_cpaddons_dir -d /home/user/public_html/cpaddons/path/on/cphost/here -u user -a bz2 -v myvendor
This will make /home/user/public_html/cpaddons/path/on/cphost/here a cPanel Sync directory with all files owned by user and from the vendor 'myvendor'. The -a bz2 is required for all addons.
For more information on the script: ./cpanelsync_build_cpaddons_dir
Copyright © cPanel 2000-2009.