Created
February 28, 2015 21:29
-
-
Save atmoz/08aa2aa6cc7788e0ddd7 to your computer and use it in GitHub Desktop.
A fun little script that changes wordpress passwords in a docker-compose setup with wordpress and mysql.
This file contains 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 | |
dbContainer="db" | |
userTable="wordpress.users" | |
username=${1:-"admin"} | |
password=${2:-"$username"} | |
passwordHash=$(docker run --rm -it -v $(pwd)/www:/www php:5.4-cli php -r "\ | |
include '/www/wp-includes/pluggable.php';\ | |
define('ABSPATH', '/www/');\ | |
echo wp_hash_password('$password');") | |
dbId=$(docker-compose ps -q $dbContainer) | |
docker exec -i $dbId bash -c "mysql -uroot -p\$MYSQL_ROOT_PASSWORD" <<ESQL | |
UPDATE $userTable SET user_pass = "$passwordHash" WHERE user_login = "$username"; | |
ESQL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment