Hi
Because we were not satisfied with the default proxy-subdomain creation of cpanel/whm, we try to create our own.
For domains / parked domains / addon-domains this was no problem by editing the Zone-Template files.
Unfortunately I could not find something similar for subdomains... that's why i'm trying to create something manually.
I tried it with the CustomEventHandler.pm as follows:
when i create a subdomain in cpanel, it gets created normally and this script has no effect.
Can someone help me figure out why? Is there an easier solution to accomplish this?
Following should be done:
- user creates subdomain
- system creates several custom dns-entries based on this subdomain
¨
Greetings
Marcel
Because we were not satisfied with the default proxy-subdomain creation of cpanel/whm, we try to create our own.
For domains / parked domains / addon-domains this was no problem by editing the Zone-Template files.
Unfortunately I could not find something similar for subdomains... that's why i'm trying to create something manually.
I tried it with the CustomEventHandler.pm as follows:
Code:
package Cpanel::CustomEventHandler;
# cpanel12 - CustomEventHandler.pm Copyright(c) 2012 cPanel, Inc.
# All rights Reserved.
# [email protected] http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
use strict;
use Cpanel::Logger ();
# api_version = api_version
# type = pre,post
# module = Cpanel::<modname>
# event = the event ie addpop
# cfg ref is a hash of the conf variables passed to the event. If its a legacy event, the hash keys are numbered, newer events have names.
# dataref = the data returned from the event (post events only)
sub event {
my ( $api_version, $type, $module, $func, $cfgref, $dataref ) = @_;
## UAPI note: $api_version will be '3', and the method signature becomes the similar:
## my ( $api_version, $type, $module, $func, $args, $result ) = @_;
if ($module eq 'subdomain') {
if ($func eq 'addsubdomain') {
if ($type eq 'post') {
my $hdata = $cfgref->[0];
my $sub = $hdata->{'domain'};
my $domain = $hdata->{'rootdomain'};
#require Cpanel::API
Cpanel::API::execute( 'ZoneEdit', 'add_zone_record', { domain => $domain, name => 'autoconfig.' . $sub, type => 'CNAME', cname => $domain . '.' } );
}
}
}
return 1;
}
1;
Can someone help me figure out why? Is there an easier solution to accomplish this?
Following should be done:
- user creates subdomain
- system creates several custom dns-entries based on this subdomain
¨
Greetings
Marcel