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.

What command would change all cpanel themes?

Discussion in 'General Discussion' started by mousepotatoe, Jan 13, 2004.

  1. mousepotatoe

    mousepotatoe Active Member

    Joined:
    Dec 17, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    I have imported a lot of domains that have a theme that i do not have on my new server. What command would I run to set all themes to, say.. blue lagoon?

    Thanks!
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    The themes are stored in the /var/cpanel/users/username files. What you want to do is replace the theme name in each "RS=themename" line with the theme you want.

    This thread in dgbaker's forum has a script that may make it easier to do the search/replace.


    edit: corrected path :eek:
     
    #2 PWSowner, Jan 13, 2004
    Last edited: Jan 13, 2004
  3. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Correction, its /var/cpanel/users.

    To change all the themes, i.e replace them, use the following.

    PHP:

    #! /bin/sh
    # filename: replaceall
    find . -type f -name '*' -print | while read i
    do
      
    sed 's|OLDTHEME|NEWTHEME|g' $i $i.tmp && mv $i.tmp $i
    done


    Just save the above file as "replaceall". Make it executable,

    chmod +x replaceall

    Now go to the directory /var/cpanel/users and run the above shell script. This will replace all instances of OLDTHEME inside the user files with NEWTHEME.

    I use the above script lot of places to search and replace in multiple files. Its fast and works! :D

    Hope this helps.
     
  4. mousepotatoe

    mousepotatoe Active Member

    Joined:
    Dec 17, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    What is the command to execute replaceall

    Thanks for your help!

    I've saved the above code and have it in /var/cpanel/users but dont know exactly how to execute it in ssh.

    I tried run replaceall (hoping the dos command would work) but no luck there. What command would execute the replaceall file?

    Thanks!
     
  5. Jeewhizz

    Jeewhizz Well-Known Member

    Joined:
    Mar 12, 2003
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    London, England
    type ./replaceall
     
  6. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Re: What is the command to execute replaceall

    Incase you want to run any shell script / program you need to either type the complete path of that script or cd to the directory and do this

    ./scriptname

    You can substitute scriptname with any program name as well.
     
  7. 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
    Re: Re: What is the command to execute replaceall

    Also if the path to the script is set in the Environment Path then it can be executed from anywhere.
     
  8. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Re: Re: Re: What is the command to execute replaceall

    correct. i sud have mentioned that.

    Thx dgbaker.
     
  9. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    This is a great process, thanks..

    Also can I use this to change the themes for packages?
     
  10. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Thats a universal search and replace script. It sud work for you.

    However i wud advise you to run this script twice.

    First change the theme name for all users. And then change the theme in all packages. Because if you change just package themes, the users using it won't be moved to the theme unless their indivisual files be edited.

    Hope i am not confusing you ;)
     
  11. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    you are welcome :D
     
  12. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    OOOOOhh man I am in a pickle.

    I changed the theme from the old termt o the new term but the old term was also used for emails and other settings so the now none of the stuff works.

    So I changed it back, but now all x is changed to the old term.

    Basically I am 50 times worse then where I started.

    Anyways just wondering if you have any ideas of how I might be able to change all referances to the old term to x without changing everything.
     
  13. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Selective replacement ? Have no idea. However now proceed the way i said in my post above.

    First replace all packages theme to X
    Then replace all users theme to X

    This should make all your users work. If they don't let me know.
     
  14. Higgins

    Higgins Well-Known Member

    Joined:
    Jan 31, 2003
    Messages:
    82
    Likes Received:
    0
    Trophy Points:
    6
    Ummpf :( Script works good and Replaces all "X" in the Users File with the new Value eg. if you have a Domain named abcx.tld and you will Replace the Style "X" with "newstyle" it will Replace your Domain abcx.tld with abcnewstyle.tld
     
  15. DWHS.net

    DWHS.net Well-Known Member
    PartnerNOC

    Joined:
    Jul 28, 2002
    Messages:
    1,569
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    LA, Costa RIca
    cPanel Access Level:
    Root Administrator
    Yep my bad, I should of thought it through..

    No biggie it's cleared up now and I am very famiar with /var/cpanel/users directory now :D
     
  16. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    good to know its cleared.
     
  17. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    A bit too late, but this is what I do (assuming /var/cpanel/users.bak doesn't exist):

    # cd /var/cpanel/
    # cp -a users users.bak
    # cd users
    # replace "RS=oldtheme" "RS=newtheme" -- *
     
  18. anand

    anand Well-Known Member

    Joined:
    Nov 11, 2002
    Messages:
    1,435
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    The same can be achieved with my script as well.

    PHP:
    #! /bin/sh
    # filename: replaceall
    find . -type f -name '*' -print | while read i
    do
      
    sed 's|RS=OLDTHEME|RS=NEWTHEME|g' $i $i.tmp && mv $i.tmp $i
    done
     
Loading...

Share This Page