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 copy Customized Error Pages to all users

Discussion in 'General Discussion' started by d-woo, Dec 2, 2006.

  1. d-woo

    d-woo Well-Known Member

    Joined:
    Aug 9, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Hi guys,

    I need help with some syntax.

    I have some customized error pages:

    /error_master/400.shtml
    /error_master/401.shtml
    /error_master/403.shtml
    /error_master/404.shtml


    that I would like to copy to the public_html of all of my users in /var/cpanel/users

    I am basing this off of the script given by forum member brianoz on this post http://forums.cpanel.net/showthread.php?t=57111

    Can you please check my syntax?

    Code:
    cd /home
    for user in `ls /var/cpanel/users`
    do
         test ! -d $user && continue
    
    	cp /error_master/400.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/400.shtml
    
    	cp /error_master/401.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/401.shtml
    
    	cp /error_master/403.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/403.shtml
    
    	cp /error_master/404.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/404.shtml
    
    	cp /error_master/500.shtml /home/$user/public_html -R
    	chown $user.$user /home/$user/public_html/500.shtml
    
    
         echo $user complete
    done
    I would save it as /home/error_insert

    Would I run it by exectuing ./error_insert in /home ?
     
  2. d-woo

    d-woo Well-Known Member

    Joined:
    Aug 9, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    okay..got this working :)

    1. log in SSH as root
    cd /

    2. create the file
    touch install_error_files
    pico install_error_files

    3.insert/paste the code (by right-clicking in Putty)
    Code:
    #! /bin/sh
    cd /home
    for user in `ls /var/cpanel/users`
    do
         test ! -d $user && continue
    
    	cp /error_master/400.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/400.shtml
    
    	cp /error_master/401.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/401.shtml
    
    	cp /error_master/403.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/403.shtml
    
    	cp /error_master/404.shtml /home/$user/public_html -R
    	chown $user:$user /home/$user/public_html/404.shtml
    
    	cp /error_master/500.shtml /home/$user/public_html -R
    	chown $user.$user /home/$user/public_html/500.shtml
    
    
         echo $user complete
    done
    4. Save and Exit Pico
    Ctrl X >> Y >> {enter}

    5. chmod the file as 700
    chmod 700 install_error_files

    4. Run the script
    ./install_error_files

    Worked like a charm!
     
Loading...

Share This Page