#!/bin/bash # Default database path DB_PATH="./backend/data/pocket-id.db" # Parse command-line arguments for the -d flag (database path) while getopts ":d:" opt; do case $opt in d) DB_PATH="$OPTARG" ;; \?) echo "Invalid option -$OPTARG" >&2 exit 1 ;; esac done shift $((OPTIND - 1)) # Ensure username or email is provided as a parameter if [ -z "$1" ]; then echo "Usage: $0 [-d ] " echo " -d Specify the database path (optional, defaults to ./backend/data/pocket-id.db)" exit 1 fi USER_IDENTIFIER="$1" # Check if sqlite3 is installed, if not install it via apk if ! command -v sqlite3 &>/dev/null; then if command -v apk &>/dev/null; then echo "sqlite3 not found. Installing..." apk add sqlite3 --no-cache else echo "sqlite3 is not installed, please install it manually." exit 1 fi fi # Generate a 16-character alphanumeric secret token SECRET_TOKEN=$(LC_ALL=C tr -dc 'A-Za-z0-9' /login/$SECRET_TOKEN" else echo "Error creating access token." exit 1 fi