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.

Script to add wildcard for 100 domain

Discussion in 'General Discussion' started by vickyingle5, Nov 7, 2007.

  1. vickyingle5

    vickyingle5 Member

    Joined:
    Oct 24, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I want to add wildcard entry for my 100 domains, to do it manually is a very tedious job. like make change in httpd.conf and named.conf , so can you suggest me some script which will add the entries in both the files ... Please help me soon , as you guys are genius :)

    Its Veryyy urgent guys ...

    Thanks in advance
     
  2. wsenter

    wsenter Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Texas
    I'm not sure in terms of how to write a script that edits the actual files in Unix. Is there a way to manually do it through cPanel? Cause you could then write something using php/curl and a while loop to go through and do it quite a few times.
     
  3. vickyingle5

    vickyingle5 Member

    Joined:
    Oct 24, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    Can n e 1 help me.
    The details for the issue is as follows:

    I have a file which contains 100 domains :
    and then I need to add a line for the wild characters for each domain in the file httpd.conf and named.conf

    In httpd.conf I want to append a line next to ServerAlias ( *.domainname )
    In named.conf I want to append a line *.domainname A ....

    Please help me with the script.

    Thanks


     
  4. wsenter

    wsenter Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Texas
    Is there a way to manually do 1 entry in cpanel? If so let me know how to do that and I might be able to whip something together for you.

    I'm fully aware that you do not want to manually enter these. I just want to see how to manually enter 1 IN CPANEL (to see how it works) and I'll see what I can do.
     
  5. vickyingle5

    vickyingle5 Member

    Joined:
    Oct 24, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Thanks wsenter,

    Ok, we need to open the file /etc/httpd/conf/httpd.conf file and the search for the domain which is present in /etc/domain.txt , after finding the virtual host entry for that domain, we need to go to ServAlias section and then append the word *.domainname and then same goes for /etc/named.conf file we need to find the entry for the domain, then go to that particular domainname.db file and append a A record which looks like *.domainname A ....

    I hope I'm clear to you, if you can show me some sample codes to do this task, I can then try to tune it.

    C yaa


     
  6. vickyingle5

    vickyingle5 Member

    Joined:
    Oct 24, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I think there are no good programmers here :)

    Guys I need some help .... Thanks
     
  7. wilburburns

    wilburburns Member

    Joined:
    Nov 3, 2003
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Well, I'm definetely not a Good Programmer, but I can hack my way through tasks like this using a variety of online documentation, tutorials, and examples.

    I won't even begin to start writing this for you, but will try and point you in the right direction.
    Sounds like you will need a Bash or similar script, so you should start looking here.
    http://tldp.org/LDP/abs/html/

    You would also need a while loop to read a file line by line... I believe I have used this one before, because it's Bookmarked..
    http://www.linuxquestions.org/questions/programming-9/bash-read-entire-file-line-in-for-loop-240016/

    And I would likely use sed make the changes to the files as necessary...
    ex: sed s/searchstring/replacestring/
    My Bookmark for sed info..
    http://www.grymoire.com/Unix/Sed.html

    I highly suggest making copies of the files you plan to edit and test thoroughly on them before working on a live file.

    Then don't forget to restart bind and httpd when done.

    And one last thing, httpd.conf is a really ugly file due to the way CPanel writes and appends to the file, so be very careful with your search string when using sed. You could easily bust Apache quickly. And DON'T FORGET TO KEEP BACKUPS....


    Good Luck
    Cliff
     
Loading...

Share This Page