From e40c2b4ce7267e0d78f328399cd334bf883341a0 Mon Sep 17 00:00:00 2001 From: Aliaksei Karneyeu Date: Thu, 26 Feb 2026 15:00:43 +0100 Subject: [PATCH] Allow creating custom user --- packages/db/setup.sh | 9 +++++++++ self-hosting/docker-compose/.env.example | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/db/setup.sh b/packages/db/setup.sh index 718912f46..0a6253fd0 100755 --- a/packages/db/setup.sh +++ b/packages/db/setup.sh @@ -24,3 +24,12 @@ if [ -z "${NO_DEMO_USER}" ]; then psql --host $PG_HOST --username $POSTGRES_USER --dbname $PG_DB --command "INSERT INTO omnivore.user (id, source, email, source_user_id, name, password) VALUES ('$USER_ID', 'EMAIL', 'demo@omnivore.work', 'demo@omnivore.work', 'Demo User', '$PASSWORD'); INSERT INTO omnivore.user_profile (user_id, username) VALUES ('$USER_ID', 'demo_user');" echo "created demo user with email: demo@omnivore.work, password: demo_password" fi + +# create a custom user if USER_EMAIL and USER_PASSWORD are set +if [ -n "${USER_EMAIL}" ] && [ -n "${USER_PASSWORD}" ]; then + USER_ID=$(uuidgen) + HASHED_PASSWORD=$(node -e "const bcrypt = require('bcryptjs'); console.log(bcrypt.hashSync(process.env.USER_PASSWORD, 10));") + USERNAME=$(echo "${USER_EMAIL}" | sed 's/@.*//' | tr -cd '[:alnum:]_') + psql --host $PG_HOST --username $POSTGRES_USER --dbname $PG_DB --command "INSERT INTO omnivore.user (id, source, email, source_user_id, name, password) VALUES ('$USER_ID', 'EMAIL', '${USER_EMAIL}', '${USER_EMAIL}', '${USER_NAME:-$USERNAME}', '$HASHED_PASSWORD'); INSERT INTO omnivore.user_profile (user_id, username) VALUES ('$USER_ID', '${USERNAME}');" + echo "created user with email: ${USER_EMAIL}" +fi diff --git a/self-hosting/docker-compose/.env.example b/self-hosting/docker-compose/.env.example index f414eb7d0..0ee353134 100644 --- a/self-hosting/docker-compose/.env.example +++ b/self-hosting/docker-compose/.env.example @@ -14,6 +14,16 @@ PG_USER=app_user PG_PORT=5432 PG_POOL_MAX=20 +# User creation + +# If you don't want to create demo user set this variable to any non-empty value +# so would be created user with email 'demo@omnivore.work' and password 'demo_password' +NO_DEMO_USER="" + +# If you need to create custom user fill in those variables +USER_EMAIL="" +USER_PASSWORD="" + # API API_ENV=local