31 lines
584 B
Bash
31 lines
584 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
mkdir -p /app/uploads
|
|
chmod 755 /app/uploads
|
|
|
|
python - <<'PY'
|
|
import os
|
|
import app as m
|
|
with m.app.app_context():
|
|
m.init_db()
|
|
m.generate_flag_at_boot()
|
|
print("DB & flag initialized.")
|
|
PY
|
|
|
|
FLAG_PATH="${FLAG_PATH:-/app/flag.txt}"
|
|
|
|
if [ -d "$FLAG_PATH" ]; then
|
|
if [ -f "$FLAG_PATH/flag.txt" ]; then
|
|
chown root:root "$FLAG_PATH/flag.txt" || true
|
|
chmod 444 "$FLAG_PATH/flag.txt" || true
|
|
fi
|
|
else
|
|
if [ -f "$FLAG_PATH" ]; then
|
|
chown root:root "$FLAG_PATH" || true
|
|
chmod 444 "$FLAG_PATH" || true
|
|
fi
|
|
fi
|
|
|
|
exec python app.py
|