# 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 and try to install the required commands check_and_install() { local cmd=$1 local pkg=$2 if ! command -v "$cmd" &>/dev/null; then if command -v apk &>/dev/null; then echo "$cmd not found. Installing..." apk add "$pkg" --no-cache else echo "$cmd is not installed, please install it manually." exit 1 fi fi } check_and_install sqlite3 sqlite check_and_install uuidgen uuidgen # 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