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.

help regarding shell script deal with httpd.conf

Discussion in 'General Discussion' started by s_2_s, Feb 2, 2006.

Thread Status:
Not open for further replies.
  1. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello
    i have an urgent issue and i need to make a shell script that read the username and domain for every entery in the httpd.conf

    for exampel

    <VirtualHost xxx.xxx.xxx.xxx>
    ServerAlias www.domain.com domain.com
    ServerAdmin webmaster@domain.com
    DocumentRoot /home/username/public_html
    BytesLog domlogs/domain.com-bytes_log
    ServerName www.domain.com
    User username
    Group username
    CustomLog domlogs/domain.com combined
    ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/
    </VirtualHost>


    i want to make a shell script to make a loop that tells me the $username and the $domainname for each and every virtualhost entery inside the httpd.conf


    your help will be so much appreciated
    i have a giid knowledge in php but i'm a newbie to shell and have a limitted info regarding it
    thats why i need anybody to lend me a hand doing this part
     
  2. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello
    i would be so grateful if any kind person help me regarding my request very much
     
  3. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    hello
    why nobody trying to help me in this
    i can't believe that its too hard for poeple here
    i didn't get even 1 reply !
     
  4. dgbaker

    dgbaker Well-Known Member
    PartnerNOC

    Joined:
    Sep 20, 2002
    Messages:
    2,578
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Toronto, Ontario Canada
    cPanel Access Level:
    DataCenter Provider
    Patience.....

    Try this to see if it gives you enough of what you need.

    Code:
    cd /usr/local/apache/conf
    grep -E "User |ServerAlias" httpd.conf
    
     
  5. WestBend

    WestBend Well-Known Member

    Joined:
    Oct 12, 2003
    Messages:
    173
    Likes Received:
    0
    Trophy Points:
    16
    Shame there is no reply thanking you dgbaker...


    Anyways thanks dgbaker, I hadnt thought of this as a way to get more than 1 piece of info out of a text file.
     
  6. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16

    hello thanks alot for your contribution
    i wrote here late as i gave up hope that poeple here would help me
    but thanks to you , you brought me the trust back

    i did your command and it doesn't output what i really need

    here is an idea of what i need


    for i in `grep -E "ServerAlias " httpd.conf`; do

    # the $i should be the domain name
    # i should get another $i2 which will be the username of that domain
    # i will write the script that will creat the lost cpanel file here

    ; done



    the problem is that how do i get $i1 (the domain name ) and $i2 from the httpd.conf so i can make a script to creat the lost cpanel user file


    please do help i depend on you
     
  7. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    anybody please ?
     
  8. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    If you have more knowledge of PHP, why don't you just write your script in PHP?
    PHP's CLI interface lets you do your shell scripting directly in PHP.

    Oh by the way, might find these useful and related to what you are trying to do ...

    /var/cpanel/users/
    /etc/userdomains
     
  9. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    /var/cpanel/users/
    /etc/userdomains

    these two were corrupt and i copied them from old backup
    however httpd.conf was intact
    so i want to use httpd.conf to recreat the missed enteries in the /var/cpanel/users/*

    i hope anybody help me its so urgent and need your help
     
  10. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    guys !
    anybody able to help ?
     
  11. kosmo

    kosmo Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    403
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    All over Europe
    Since as you say, you have php knowledge: this is something you can do in php (and run the script in ssh while logged in as root). Why do you need a shell script?

    kosmo
     
  12. rpmws

    rpmws Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    1,824
    Likes Received:
    5
    Trophy Points:
    38
    Location:
    back woods of NC, USA
    I wouldn't be suprised if there is already a script in /scripts/ that is designed to do what he needs to do. i often find scripts in there that bail you out of trouble at times.
     
  13. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello
    i'm still waiting somebody to offer help
    i really need it
    and thanks to poeple who posted in this thread
     
  14. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    dgbaker please follow up with me :(
     
  15. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    chirpy please reply to this subject
     
  16. dgbaker

    dgbaker Well-Known Member
    PartnerNOC

    Joined:
    Sep 20, 2002
    Messages:
    2,578
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Toronto, Ontario Canada
    cPanel Access Level:
    DataCenter Provider
    Not sure why you are asking for myself and Chirpy to reply. We have given advise along with others here as well. People will only reply if they have a solution or can help. As I'm not aware of an easy for you to do what your asking, there was no sense in replying.
     
  17. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    does this get you close to what you want?

    Code:
    awk '/VirtualHost|ServerAlias|User/ {print $1,$2 }' httpd.conf |sed -e 's/>//'|sed -e 's_</VirtualHost_\n_'|sed -e 's/<//'
     
  18. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello

    dgbaker , i was calling you in because you are a cpanel forum moderator ,
    my reply is not " no sense" but having information and not sharing it is what should be called " no sense "

    i'm so thankful for each and every person who tried to help as much as they could


    h2oski, thanks alot for your contribution but it does give output similar to

    VirtualHost xx.x.x.x.x.x
    ServerAlias domain.com
    UserDir disabled
    UserDir enabled
    User username


    all what i need to do is to make a loop that will print $user and $domain for each domain so i can think of how i can write them to a valid format cpanel user file so the sites can be managed and show no cpanel errors anymore

    thanks all again
     
  19. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6

    This may do what you want
    Code:
    awk '/<\/VirtualHost>|ServerAlias|User / {print $2 }' httpd.conf.gsm|grep -v '</VirtualHost>'
    if the fomat is what you want just end the command with > output_filename.txt


    I don't understand what you said about the 'valid format cpanel user file so the sites can be managed and show no cpanel errors'
     
  20. s_2_s

    s_2_s Well-Known Member

    Joined:
    Aug 9, 2004
    Messages:
    215
    Likes Received:
    0
    Trophy Points:
    16
    Hello
    thanks for your help and for following up with me

    the problem i'm facing to let you understand it is as follows

    the hdd failed
    i could copy all data from the failed hdd except for /var/cpanel/users and localuserdomains file


    so all what i'm trying to do is to generate valid /var/cpanel/users files from the httpd.conf becuase cpanel doens't want to work unless this file is present
     
Loading...
Thread Status:
Not open for further replies.

Share This Page