-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·101 lines (85 loc) · 3.14 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·101 lines (85 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
set -e
START_DIR="$(pwd)"
# --- Ensure we’re in the script’s directory (project root) ---
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# --- 1. Create .env if missing ---
if [ ! -f ".env" ]; then
echo "Creating default .env file..."
SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
cat > .env <<EOF
###############################################################################
# FOR TIMESCALE BACKED PROJECTS
###############################################################################
# This assumes the backend services are being run via docker. Change DB_HOST to
# 'localhost' if running locally
# DB_HOST=timescaledb
# DB_PORT=5432
########################
# POSTGRESQL Settings
########################
# POSTGRES_USER=postgres
# POSTGRES_PASSWORD=password
# POSTGRES_DB=odt_project_db
########################
# PGADMIN Settings
########################
# PGADMIN_DEFAULT_EMAIL=admin@example.com
# PGADMIN_DEFAULT_PASSWORD=password
###############################################################################
# FOR SQLITE BACKED PROJECTS
###############################################################################
DATABASE_URL=sqlite+aiosqlite:///./db.sqlite3
###############################################################################
# Default admin account - DELETE AFTER DB INITIALIZATION
###############################################################################
DEFAULT_ADMIN_USERNAME=admin
DEFAULT_ADMIN_PASSWORD=admin
DEFAULT_ADMIN_FULLNAME=Administrator
DEFAULT_ADMIN_EMAIL=odt_project_admin@oceandatatool.org
###############################################################################
# Backend settings
###############################################################################
SECRET_KEY=$SECRET_KEY
ACCESS_TOKEN_EXPIRE_MINUTES=15
REFRESH_TOKEN_EXPIRE_DAYS=7
FRONTEND_URL=http://localhost:5173
###############################################################################
# Set to Production before deploying
###############################################################################
ENVIRONMENT=Development
###############################################################################
# Email Settings
###############################################################################
#SENDGRID_API_KEY=SG.xxxxxxx
#SENDGRID_FROM_EMAIL=noreply@oceandatatools.org
EOF
echo ".env created."
else
echo ".env already exists, skipping."
fi
# --- 2. Install dependencies ---
if command -v poetry &>/dev/null; then
echo "Installing dependencies with Poetry..."
poetry install --no-root
else
echo "Poetry not found. Using venv + pip fallback..."
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt
elif [ -f "pyproject.toml" ]; then
pip install poetry
poetry export -f requirements.txt --without-hashes -o requirements.txt
pip install -r requirements.txt
fi
fi
# --- 3. Create db.sqlite3 if missing ---
if [ ! -f "./db.sqlite3" ]; then
echo "Creating SQLite database file..."
touch ./db.sqlite3
fi
cd "$START_DIR"
echo "Setup complete."