diff --git a/scripts/create-one-time-access-token.sh b/scripts/create-one-time-access-token.sh index 0eb13e8..30a4f73 100644 --- a/scripts/create-one-time-access-token.sh +++ b/scripts/create-one-time-access-token.sh @@ -1,5 +1,6 @@ -# Default database path DB_PATH="./backend/data/pocket-id.db" +DB_PROVIDER="${DB_PROVIDER:=sqlite}" +USER_IDENTIFIER="$1" # Parse command-line arguments for the -d flag (database path) while getopts ":d:" opt; do @@ -19,12 +20,12 @@ 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)" + if [ "$DB_PROVIDER" == "sqlite" ]; then + echo "-d (optional): Path to the SQLite database file. Default: $DB_PATH" + fi exit 1 fi -USER_IDENTIFIER="$1" - # Check and try to install the required commands check_and_install() { local cmd=$1 @@ -41,8 +42,12 @@ check_and_install() { fi } -check_and_install sqlite3 sqlite check_and_install uuidgen uuidgen +if [ "$DB_PROVIDER" == "postgres" ]; then + check_and_install psql postgresql-client +elif [ "$DB_PROVIDER" == "sqlite" ]; then + check_and_install sqlite3 sqlite +fi # Generate a 16-character alphanumeric secret token SECRET_TOKEN=$(LC_ALL=C tr -dc 'A-Za-z0-9' }/login/$SECRET_TOKEN" @@ -73,3 +104,4 @@ else echo "Error creating access token." exit 1 fi +echo "================================================="