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.

Replace a Single File Across Users

Discussion in 'General Discussion' started by KoiHosting, Jun 21, 2010.

  1. KoiHosting

    KoiHosting Registered

    Joined:
    Apr 21, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    We have created a reseller account for a client of ours.
    The reseller account has 205 accounts in it.
    The reseller is also the end user, (in other words, all the accounts are his, and not other peoples) so there are no permissions issues.
    The reseller needs to be able to replace a single file in the same directory in all 205 of his accounts.

    We have uploaded one "fixed" file to one of his accounts.

    Is there a simple way of copying that file to his other accounts, and overwrite the file that exists, and replacing it with the fix?

    A simple unix shell command perhaps?

    Thank you.
     
  2. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    817
    Likes Received:
    22
    Trophy Points:
    18
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    You'd have to run this as root so you can write to multiple accounts, or give the reseller user sudo access to cp:

    Code:
    
    #!/bin/bash
    RESELLER=user1  # username of reseller user
    SOURCEPATH=path   # path of source file being copied
    SOURCEFILE=file # name of source file being copied
    PATH=folder  # path from destination user home (ie public_html/folder/)
    
    for user in `cat /etc/trueuserowners |grep $RESELLER | awk '{print $1}' | cut -d: -f1`
      do
          cp $SOURCEPATH/$SOURCEFILE /home/$user/$PATH
          chown $user:user /home/$user/$PATH/$SOURCEFILE
    
      done
    
    
    
    
     
    #2 vanessa, Jun 21, 2010
    Last edited: Jun 21, 2010
  3. KoiHosting

    KoiHosting Registered

    Joined:
    Apr 21, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Thanks Vanessa

    It worked like a charm!
     
Loading...

Share This Page