1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #!/usr/bin/env bash
- # Function to create admin user
- create_admin_user() {
- USERNAME="admin"
- EMAIL="admin@example.com"
- FIRSTNAME="Admin"
- LASTNAME="Admin"
- PASSWORD="Admin123"
- bin/magento admin:user:create \
- --admin-user="${USERNAME}" \
- --admin-password="${PASSWORD}" \
- --admin-email="${EMAIL}" \
- --admin-firstname="${FIRSTNAME}" \
- --admin-lastname="${LASTNAME}"
- if [ $? -eq 0 ]; then
- echo "Admin account created successfully."
- echo "Username: ${USERNAME}"
- echo "Email: ${EMAIL}"
- echo "Firstname: ${FIRSTNAME}"
- echo "Lastname: ${LASTNAME}"
- echo "Password: ${PASSWORD}"
- else
- echo "Error creating admin user."
- fi
- }
- # Function to create customer account
- create_customer_account() {
- EMAIL="${EMAIL:-customer@example.com}"
- PASSWORD="${PASSWORD:-customer123QWERTY}"
- FIRSTNAME="${FIRSTNAME:-Customer}"
- LASTNAME="${LASTNAME:-Customer}"
- WEBSITE="${WEBSITE:-1}"
- bin/n98-magerun2 customer:create "${EMAIL}" "${PASSWORD}" "${FIRSTNAME}" "${LASTNAME}" "${WEBSITE}"
- if [ $? -eq 0 ]; then
- echo "Customer account created successfully."
- echo "Email: ${EMAIL}"
- echo "Firstname: ${FIRSTNAME}"
- echo "Lastname: ${LASTNAME}"
- echo "Password: ${PASSWORD}"
- else
- echo "Error creating customer account."
- fi
- }
- # Check if n98-magerun2.phar exists, if not download and install
- if ! bin/cliq ls bin/n98-magerun2; then
- echo "Checking if n98-magerun2.phar exists, just a moment..."
- bin/clinotty curl -sS -O https://files.magerun.net/n98-magerun2.phar
- bin/clinotty curl -sS -o n98-magerun2.phar.sha256 https://files.magerun.net/sha256.php?file=n98-magerun2.phar
- bin/clinotty shasum -a 256 -c n98-magerun2.phar.sha256
- [ $? != 0 ] && echo "sha256 checksum do not match!" && exit
- bin/cliq chmod +x n98-magerun2.phar
- bin/cliq mkdir -p bin
- bin/cliq mv n98-magerun2.phar bin
- fi
- # Prompt user for type of account to create
- read -r -p "Do you want to create an admin (A) or a customer (C) account? [A/C]: " account_type
- if [[ "$account_type" == "A" || "$account_type" == "a" ]]; then
- create_admin_user
- elif [[ "$account_type" == "C" || "$account_type" == "c" ]]; then
- read -r -p "Do you want to use default values for customer account? (Y/N): " use_defaults
- if [[ "$use_defaults" == "Y" || "$use_defaults" == "y" ]]; then
- create_customer_account
- elif [[ "$use_defaults" == "N" || "$use_defaults" == "n" ]]; then
- read -r -p "Enter customer email: " EMAIL
- read -r -p "Enter customer password: " PASSWORD
- read -r -p "Enter customer firstname: " FIRSTNAME
- read -r -p "Enter customer lastname: " LASTNAME
- read -r -p "Enter customer website: " WEBSITE
- create_customer_account
- else
- echo "Invalid option. Please choose either Y or N."
- fi
- else
- echo "Invalid option. Please choose either A or C."
- fi
|