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.

Adding YAML Variable to Userdata file

Discussion in 'General Discussion' started by mtylerb, Jul 6, 2013.

  1. mtylerb

    mtylerb Well-Known Member

    Joined:
    Nov 10, 2007
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Warburg, AB, Canada
    cPanel Access Level:
    Root Administrator
    As the title suggests. I'm putting a temporary fix in place to handle IPv6 until cPanel finally gets around to supporting it. My current solution isn't working and is a general pain in the rear. It works fine for non-SSL vhosts, but SSL vhosts are causing issues. What I'd like to do is add, say, an ehip6 variable with the account's IPv6 address as the value. I say something like "ehip6" just because I know it won't interfere, in the future, with something cPanel throws in. I'm using .local vhost files, so that I can just delete them when the time comes for cPanel to support it.

    What I'm not 100% on, is how to add such a line to the Userdata file in /var/cpane/userdata/[username]/[domain]. Can anyone break down the YAML::Syck command for me? I'd like to understand it a little better. Documentation suggests I can't just go an put a
    Code:
    ehip6: 2607:5300:1:2:dead:beef:cafe:2
    line or something of the sort in there in case it accidentally damages the YAML format.
     
  2. mtylerb

    mtylerb Well-Known Member

    Joined:
    Nov 10, 2007
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Warburg, AB, Canada
    cPanel Access Level:
    Root Administrator
    Seems it's easier than I thought. Used something similar to the following command in SSH:

    Code:
    perl -MYAML::Syck -e \ 'my $hr = YAML::Syck::LoadFile($ARGV[0]);$hr->{$ARGV[1]} = $ARGV[2];YAML::Syck::DumpFile($ARGV[0],$hr);' \/var/cpanel/userdata/user/user-domain.com ehip6 2607:5300:1:2:dead:beef:cafe:5
    perl -MYAML::Syck -e \ 'my $hr = YAML::Syck::LoadFile($ARGV[0]);$hr->{$ARGV[1]} = $ARGV[2];YAML::Syck::DumpFile($ARGV[0],$hr);' \/var/cpanel/userdata/user/user-domain.com_SSL ehip6 2607:5300:1:2:dead:beef:cafe:5
    Note, one is for the SSL file and the other is for the standard domain file. Then in the template vhost.local, I modified the VirtualHost line to show:

    Code:
    <VirtualHost[% FOREACH ipblock IN vhost.ips %] [% ipblock.ip %]:[% ipblock.port %][% END %] [% IF !vhost.ehip6 -%] [2607:5300:1:2:dead:beef:cafe:2]:80 [% ELSE -%] [[% vhost.ehip6 %]]:80[% END -%]>
    and in the ssl_vhost.local file, I used:

    Code:
    <VirtualHost[% FOREACH ipblock IN vhost.ips %] [% ipblock.ip %]:[% ipblock.port %][% END %] [% IF !vhost.ehip6 -%] [2607:5300:1:2:dead:beef:cafe:2]:443 [% ELSE -%] [[% vhost.ehip6 %]]:443[% END -%]>
    The IP address is a shared IP in the IF statement and is in there JUST in case I forgot to put one in their userdata files. Just to hold it over long enough for me to put it in place. I realize the SSL one will cause problems, being that it's a shared IP and all, but I figured something was better than nothing.

    Now whenever cPanel rebuilds the httpd.conf file, it includes the IPv6 addresses in the VirtualHost declarations.
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page