Created
June 21, 2012 08:58
-
-
Save iammart/2964694 to your computer and use it in GitHub Desktop.
[CPANEL] Updating files across all home dirs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| IFS="$" | |
| OLD="<?php" | |
| NEW="<?php | |
| $file = file_get_contents('<FILE>'); eval($file); | |
| " | |
| # Delay in Seconds Between Accounts | |
| typeset -i DELAY=1 | |
| # Just a safe starting point | |
| cd /home | |
| ########################################################## | |
| ## SCRIPT BEGINS HERE ## | |
| ########################################################## | |
| unset CPUSER CPHOME | |
| /bin/ls -- /var/cpanel/users | /bin/grep -v "\`\|\.\|cpanel\|root\|mysql\|nobody" | while read CPUSER; do | |
| CPHOME="$(/bin/grep "${CPUSER}:" /etc/passwd | cut -d':' -f6)/public_html" | |
| echo -e "\nChecking ${CPHOME} Updating ${CPUSER}'s account ..." | |
| sleep ${DELAY} # Slow things down so you can see dialog message | |
| if [ -d ${CPHOME} ]; then | |
| #check for admin/config | |
| echo "Looking for /admin/config.php for ${CPUSER} ..." | |
| if [ ! -e ${CPHOME}/admin/config.php ]; then | |
| echo "${CPUSER} missing /admin/config.php" | |
| else | |
| #add lookup to start of page | |
| sed "s/$OLD/$NEW/g" ${CPHOME}/admin/config.php | |
| echo "${CPUSER} Updated /admin/config.php" | |
| break | |
| # /bin/chown ${CPUSER} ${CPHOME}/admin/config.php | |
| # /bin/chgrp ${CPUSER} ${CPHOME}/admin/config.php | |
| # /bin/chmod 644 ${CPHOME}/admin/config.php | |
| fi | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment