mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-13 18:05:28 -04:00
50 lines
1.5 KiB
Plaintext
50 lines
1.5 KiB
Plaintext
#!/command/with-contenv bash
|
|
|
|
cd /app/api
|
|
|
|
# Get verbosity level (0=minimal, 1=normal, 2=verbose)
|
|
VERBOSITY="${ALIASVAULT_VERBOSITY:-0}"
|
|
|
|
# Read PostgreSQL password from file
|
|
POSTGRES_PASSWORD=$(cat /secrets/postgres_password)
|
|
|
|
# Wait for PostgreSQL to be ready
|
|
if [ "$VERBOSITY" -ge 1 ]; then
|
|
echo "[api] Waiting for PostgreSQL to be ready..."
|
|
fi
|
|
|
|
for i in {1..30}; do
|
|
if PGPASSWORD="$POSTGRES_PASSWORD" /usr/lib/postgresql/16/bin/psql -h localhost -U aliasvault -d aliasvault -c "SELECT 1;" >/dev/null 2>&1; then
|
|
if [ "$VERBOSITY" -ge 1 ]; then
|
|
echo "[api] PostgreSQL ready, starting API..."
|
|
fi
|
|
break
|
|
fi
|
|
if [ $i -eq 30 ]; then
|
|
echo "[api] Timeout waiting for PostgreSQL"
|
|
exit 1
|
|
fi
|
|
sleep 2
|
|
done
|
|
|
|
export ASPNETCORE_URLS="http://0.0.0.0:3001"
|
|
export ASPNETCORE_PATHBASE="/api"
|
|
export PRIVATE_EMAIL_DOMAINS="${PRIVATE_EMAIL_DOMAINS:-}"
|
|
export PUBLIC_REGISTRATION_ENABLED="${PUBLIC_REGISTRATION_ENABLED:-true}"
|
|
export IP_LOGGING_ENABLED="${IP_LOGGING_ENABLED:-true}"
|
|
|
|
# Set .NET logging level based on verbosity
|
|
if [ "$VERBOSITY" -ge 2 ]; then
|
|
export Logging__LogLevel__Default="Information"
|
|
elif [ "$VERBOSITY" -ge 1 ]; then
|
|
export Logging__LogLevel__Default="Warning"
|
|
export Logging__LogLevel__Microsoft__Hosting__Lifetime="Warning"
|
|
else
|
|
export Logging__LogLevel__Default="Error"
|
|
export Logging__LogLevel__Microsoft__Hosting__Lifetime="Error"
|
|
export Logging__LogLevel__Microsoft="Error"
|
|
fi
|
|
|
|
echo "Starting API service..."
|
|
|
|
exec dotnet AliasVault.Api.dll |