Bash script to suspend all of a reseller's cPanel accounts
Simple Bash script to suspend all of a reseller’s user accounts on a cPanel web server. It gets an accurate list of the reseller user’s sub-accounts on the cPanel server, and suspends each of them.
You may wish to
chmod u+x ./suspend-reseller-accounts in order to make it easier to work with.
Without further delay, here’s the script. Enjoy!
#!/bin/bash # # Date: June 23rd 2015 # Author: Will Ashworth || williamashworth.com # # Suspend cPanel accounts for all users of a given reseller # account. Scripted specifically for cPanel servers on Linux. # # Copyright (C) 2015 Will Ashworth # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. http://www.gnu.org/licenses/ reseller=$1 if [ -z "$reseller" ] then echo "Reseller is empty. Please provide one! Like this..." echo "./thisscript <reseller>" else # Get the users for this reseller users=`grep $reseller /etc/trueuserowners | cut -d : -f 1` # Loop through the list of users for user in $users; do # Suspend the cPanel user account /scripts/suspendacct $user done fi
If you run into any issues, please contact me and let me know thoughts or ideas for improvement. Thanks!