|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Function to create admin user |
| 4 | +create_admin_user() { |
| 5 | + USERNAME="admin" |
| 6 | + |
| 7 | + FIRSTNAME="Admin" |
| 8 | + LASTNAME="Admin" |
| 9 | + PASSWORD="Admin123" |
| 10 | + |
| 11 | + bin/magento admin:user:create \ |
| 12 | + --admin-user=${USERNAME} \ |
| 13 | + --admin-password=${PASSWORD} \ |
| 14 | + --admin-email=${EMAIL} \ |
| 15 | + --admin-firstname=${FIRSTNAME} \ |
| 16 | + --admin-lastname=${LASTNAME} |
| 17 | + |
| 18 | + if [ $? -eq 0 ]; then |
| 19 | + echo "Admin account created successfully." |
| 20 | + echo "Username: ${USERNAME}" |
| 21 | + echo "Email: ${EMAIL}" |
| 22 | + echo "Firstname: ${FIRSTNAME}" |
| 23 | + echo "Lastname: ${LASTNAME}" |
| 24 | + echo "Password: ${PASSWORD}" |
| 25 | + else |
| 26 | + echo "Error creating admin user." |
| 27 | + fi |
| 28 | +} |
| 29 | + |
| 30 | +# Function to create customer account |
| 31 | +create_customer_account() { |
| 32 | + EMAIL= ${EMAIL:-"[email protected]"} |
| 33 | + PASSWORD=${PASSWORD:-"customer123QWERTY"} |
| 34 | + FIRSTNAME=${FIRSTNAME:-"Customer"} |
| 35 | + LASTNAME=${LASTNAME:-"Customer"} |
| 36 | + |
| 37 | + bin/n98-magerun2 customer:create ${EMAIL} ${PASSWORD} ${FIRSTNAME} ${LASTNAME} ${WEBSITE} |
| 38 | + |
| 39 | + if [ $? -eq 0 ]; then |
| 40 | + echo "Customer account created successfully." |
| 41 | + echo "Email: ${EMAIL}" |
| 42 | + echo "Firstname: ${FIRSTNAME}" |
| 43 | + echo "Lastname: ${LASTNAME}" |
| 44 | + echo "Password: ${PASSWORD}" |
| 45 | + else |
| 46 | + echo "Error creating customer account." |
| 47 | + fi |
| 48 | +} |
| 49 | + |
| 50 | +# Check if n98-magerun2.phar exists, if not download and install |
| 51 | +if ! bin/cliq ls bin/n98-magerun2; then |
| 52 | + echo "Checking if n98-magerun2.phar exists, just a moment..." |
| 53 | + bin/clinotty curl -sS -O https://files.magerun.net/n98-magerun2.phar |
| 54 | + bin/clinotty curl -sS -o n98-magerun2.phar.sha256 https://files.magerun.net/sha256.php?file=n98-magerun2.phar |
| 55 | + bin/clinotty shasum -a 256 -c n98-magerun2.phar.sha256 |
| 56 | + [ $? != 0 ] && echo "sha256 checksum do not match!" && exit |
| 57 | + |
| 58 | + bin/cliq chmod +x n98-magerun2.phar |
| 59 | + bin/cliq mkdir -p bin |
| 60 | + bin/cliq mv n98-magerun2.phar bin |
| 61 | +fi |
| 62 | + |
| 63 | +# Prompt user for type of account to create |
| 64 | +read -p "Do you want to create an admin (A) or a customer (C) account? [A/C]: " account_type |
| 65 | + |
| 66 | +if [[ "$account_type" == "A" || "$account_type" == "a" ]]; then |
| 67 | + create_admin_user |
| 68 | +elif [[ "$account_type" == "C" || "$account_type" == "c" ]]; then |
| 69 | + read -p "Do you want to use default values for customer account? (Y/N): " use_defaults |
| 70 | + if [[ "$use_defaults" == "Y" || "$use_defaults" == "y" ]]; then |
| 71 | + create_customer_account |
| 72 | + elif [[ "$use_defaults" == "N" || "$use_defaults" == "n" ]]; then |
| 73 | + read -p "Enter customer email: " EMAIL |
| 74 | + read -p "Enter customer password: " PASSWORD |
| 75 | + read -p "Enter customer firstname: " FIRSTNAME |
| 76 | + read -p "Enter customer lastname: " LASTNAME |
| 77 | + read -p "Enter customer website: " WEBSITE |
| 78 | + create_customer_account |
| 79 | + else |
| 80 | + echo "Invalid option. Please choose either Y or N." |
| 81 | + fi |
| 82 | +else |
| 83 | + echo "Invalid option. Please choose either A or C." |
| 84 | +fi |
| 85 | + |
0 commit comments