#!/bin/bash # +----+----+----+----+ # | | | | | # Author: Mark David Scott Cunningham | M | D | S | C | # +----+----+----+----+ # Created: 2016-09-05 # Updated: 2016-09-06 # # Purpose: Temporarily swap out password for admin login on CS_Cart sites # # Get the database name from the config file dbname=$(grep db_name $PWD/config.local.php | cut -d\' -f4); # Get the first available admin user and their password from the DB adminuser=$(mysql -Ne "select email from cscart_users where user_type rlike 'A' order by user_id limit 1" $dbname | cat) oldpass=$(mysql -Ne "select password from cscart_users where email=\"$adminuser\"" $dbname | cat); # Print out the current password and user login mysql -e "select user_id,user_type,email,password from cscart_users where user_type rlike 'A' order by user_id limit 1" $dbname; # Update the password to a known value mysql -e "update cscart_users set password=MD5('password') where email=$adminuser" $dbname echo " New temporary admin password for testing. Username: $adminuser Password: password You have 30 seconds before the password will be reverted. " # Visual Timer for x in {30..01}; do echo -ne " ..$x.. \r"; sleep 1; done # Revert the password from the value stored earlier mysql -e "update cscart_users set password=\"$oldpass\" where email=\"$adminuser\"" $dbname echo "Password has been reverted in the database."