Forked from ashokarun/gist:8c6cbae2266dc03a5d600700b0d2d6f5
Created
January 31, 2018 15:00
-
-
Save pelligrag/a24cb66a4c1392870a194c684b3dba54 to your computer and use it in GitHub Desktop.
Bulk database user password script
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/sh | |
echo "This script is useful for only commonly using CMSs like WP, Joomla, Drupal, Magento, Drupal etc with known configuration location. If nothing listing and you are getting db conntction error check configuration manually.. Thanks by Arunlal" | |
echo "" > details.txt | |
echo "Please enter the cPanel username: " | |
read username | |
grep -irl ${username}_ /home/$username/*{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php 2>/dev/null grep -v -E "mail|error_log|sql|html|var">> ${username}confs.txt | |
var=`cat ${username}confs.txt` | |
if [ -n "$var" ]; then | |
for i in `cat ${username}confs.txt`; do echo $i >> details.txt; grep -E "DB_USER|user|username|DB_PASSWORD|secret|password" $i |grep -v -E "cookies|generate" >> details.txt; echo "-------" >> details.txt; done | |
echo " " | |
echo "***Websites' conf and db details are listed below***" | |
echo "----------------------------------------------------" | |
cat details.txt | |
echo " " > ${username}confs.txt | |
else | |
echo "Check the database prefix manually. It seems username and db prefix are not same. Please quit the script. Enter (N/n)!!" | |
fi | |
rm -f ${username}confs.txt | |
read -p "Do you wanna reset the password from here? (y/n)?" choice | |
case "$choice" in | |
y|Y ) echo "Alright!! Please give me the following details..." | |
echo "Enter database username: " | |
read dbur | |
echo "Enter current db user password per site's configuration: " | |
read dbpw | |
echo "Enter new/same password: " | |
read dbpwnw | |
echo "Please wait...... Updating db user $dbur password..." | |
mysqladmin -u $dbur -p$dbpw password $dbpwnw | |
echo "Congratulations... DB user password has been updated";; | |
n|N ) echo "No problem dude.. Reset it from the control panel. Refer https:/www.crybit.com/change-database-user-password-cpanel/";; | |
* ) echo "Not a valid option.";; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment