-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigure.sh
executable file
·76 lines (64 loc) · 1.87 KB
/
configure.sh
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
#!/bin/bash
# Set base directories
CONFIG_DIR="./django_backend/config"
FRONTEND_DIR="./svelte_frontend"
# Print function
print_status() {
local level=$1
shift
local message=$@
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$timestamp] [$level] $message"
}
# Error handling
set -e
trap 'print_status ERROR "An error occurred on line $LINENO"' ERR
# Create config directories
print_status INFO "Creating config directories"
mkdir -p "$CONFIG_DIR"
mkdir -p "$FRONTEND_DIR"
# Function to create config files
create_config() {
local file=$1
local content=$2
local filename=$(basename "$file")
print_status INFO "Creating: $filename"
echo "$content" > "$file" && print_status INFO "Created: $filename"
}
print_status INFO "Creating configuration files..."
# db.py
create_config "$CONFIG_DIR/db.py" "from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}"
# env.py
create_config "$CONFIG_DIR/env.py" "CSRF_TRUSTED_ORIGINS = [
'http://localhost:5173',
]
DEBUG = True
PRODUCTION = False
ALLOWED_HOSTS = []
STRIPE_SECRET_KEY = 'sk_test_*'
STRIPE_WEBHOOK_SECRET_KEY = 'whsec*'
SECRET_KEY = 'django-insecure-pt50ualer8otrcli1@#@nsfqe*$f4mbtp+rug@rkyr^bia$fz!'
LOGGING = {}
SITE_ID = 1"
# mail.py
create_config "$CONFIG_DIR/mail.py" "EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = \"localhost\"
EMAIL_PORT = \"1725\"
EMAIL_HOST_USER = \"\"
EMAIL_HOST_PASSWORD = \"\"
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False
DEFAULT_FROM_EMAIL = \"[email protected]\""
# frontend .env
create_config "$FRONTEND_DIR/.env" "SECRET_BASE_API=http://localhost:8000"
# Summary
print_status INFO "Configuration setup completed"
echo -e "\nCreated files:"
find "$CONFIG_DIR" "$FRONTEND_DIR/.env" -type f -exec ls -l {} \;