2
0

create-user 2.8 KB

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