aitori-create-stylists.sh 866 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. set -eu
  3. script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
  4. project_dir=$(CDPATH= cd -- "$script_dir/.." && pwd)
  5. compose_dir="$project_dir/docker"
  6. compose_file="${COMPOSE_FILE:-docker-compose.yml}"
  7. accounts_file="$script_dir/aitori-stylist-accounts.tsv"
  8. if [ ! -r "$accounts_file" ]; then
  9. echo "凭据文件不存在或不可读: $accounts_file" >&2
  10. exit 1
  11. fi
  12. cd "$compose_dir"
  13. tail -n +2 "$accounts_file" | while IFS="$(printf '\t')" read -r id username email password; do
  14. [ -n "$id" ] || continue
  15. echo "Creating account: $email"
  16. docker compose -f "$compose_file" exec -T \
  17. -e INITIAL_STYLIST_ID="$id" \
  18. -e INITIAL_STYLIST_USERNAME="$username" \
  19. -e INITIAL_STYLIST_EMAIL="$email" \
  20. -e INITIAL_STYLIST_PASSWORD="$password" \
  21. backend node /app/prisma/seed-initial.cjs < /dev/null
  22. done
  23. echo 'Account import finished.'