Skip to content

Instantly share code, notes, and snippets.

@magenx
Last active July 1, 2021 16:34
Show Gist options
  • Save magenx/81cfacae2854f9b6819b6b39da51b65a to your computer and use it in GitHub Desktop.
Save magenx/81cfacae2854f9b6819b6b39da51b65a to your computer and use it in GitHub Desktop.
#!/bin/bash
## get n98-magerun2
curl -o /usr/local/bin/magerun2 https://files.magerun.net/n98-magerun2.phar
## reset magento admin password
MAGE_NEW_ADMIN_PASS="$(head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9!@#$%^&?=+_[]{}()<>-' | fold -w 15 | head -n 1)${RANDOM}"
read -e -p "---> Enter admin old login: " -i "admin" MAGE_OLD_ADMIN_NAME
read -e -p "---> Enter your First Name: " -i "Name" MAGE_NEW_ADMIN_FNAME
read -e -p "---> Enter your Last Name: " -i "Lastname" MAGE_NEW_ADMIN_LNAME
read -e -p "---> Enter admin login: " -i "admin" MAGE_NEW_ADMIN_NAME
read -e -p "---> Enter admin email address: " -i "admin@domain.com" MAGE_NEW_ADMIN_EMAIL
## delete admin
/usr/local/bin/magerun2 admin:user:delete ${MAGE_OLD_ADMIN_NAME} -f
## create new admin
bin/magento admin:user:create --admin-user='${MAGE_NEW_ADMIN_NAME}' --admin-password='${MAGE_NEW_ADMIN_PASS}' \
--admin-email='${MAGE_NEW_ADMIN_EMAIL}' --admin-firstname='${MAGE_NEW_ADMIN_FNAME}' --admin-lastname='${MAGE_NEW_ADMIN_LNAME}'
echo " > Magento admin login: ${MAGE_NEW_ADMIN_NAME}"
echo " > Magento admin password: ${MAGE_NEW_ADMIN_PASS}"
echo " > Magento admin email: ${MAGE_NEW_ADMIN_EMAIL}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment