Skip to content

Instantly share code, notes, and snippets.

@atmoz
Created February 28, 2015 21:29
Show Gist options
  • Save atmoz/08aa2aa6cc7788e0ddd7 to your computer and use it in GitHub Desktop.
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.
#!/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