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.

Simple way to change reseller IP and all accounts from shell?

Discussion in 'General Discussion' started by Wyatt Epp, Oct 29, 2011.

  1. Wyatt Epp

    Wyatt Epp Registered
    PartnerNOC

    Joined:
    Oct 29, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Simple way to change reseller IP from shell? [Partially Solved]

    A reseller with more than fifty resold accounts wants a static IP and wants all of his domains on it. The UI for this is rather onerous; can anyone direct me to the relevant scripts for accomplishing this without half an hour of mouse-clicking? Thanks.

    Partial Solution:
    Change reseller's shared IP in WHM (still not sure how to get that into a script), then:
    Code:
    #!/usr/bin/env bash
    RESELLER=$1
    OLDIP=$2
    NEWIP=$3
    
    for I in $(grep " $RESELLER" /etc/trueuserowners|cut -f1 -d:);do 
        if grep -q "$OLDIP" /var/cpanel/users/$I;then
            echo "$I..."
            /usr/local/cpanel/bin/setsiteip -u $I $NEWIP
        fi
    done
    
    I'm going to clean it up a bit more, but you get the gist.

    And the question remains: How can I automate this entirely?
     
    #1 Wyatt Epp, Oct 29, 2011
    Last edited: Oct 30, 2011
  2. Indianets

    Indianets Well-Known Member

    Joined:
    Jun 13, 2008
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Re: Simple way to change reseller IP from shell? [Partially Solved]

    And here you go, it was rather simpler than you could think :P

    Code:
    touch /var/cpanel/mainips/$RESELLER
    echo -n $IP > /var/cpanel/mainips/$RESELLER
    
    Integrate with above code and enjoy!

    - Vijay :D
     
Loading...

Share This Page