Fix GrampsWeb: recursive CSS find + auto-create admin on startup (STI-90)
- Use `find` instead of `*.css` glob to catch fonts/fonts.css in subdirs - Add Python script to auto-create Admin user if no users exist yet Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
22
compose.yml
22
compose.yml
@@ -232,8 +232,8 @@ services:
|
||||
echo "[grampsweb] patched JS paths: $$f"
|
||||
fi
|
||||
done
|
||||
for f in /app/static/*.css; do
|
||||
if [ -f "$$f" ] && grep -q 'fonts/' "$$f" 2>/dev/null; then
|
||||
find /app/static -name '*.css' 2>/dev/null | while read f; do
|
||||
if grep -q '\.\./fonts/' "$$f" 2>/dev/null; then
|
||||
sed -i "s|'../fonts/|'fonts/|g" "$$f"
|
||||
sed -i "s|\"../fonts/|\"fonts/|g" "$$f"
|
||||
echo "[grampsweb] patched CSS font paths: $$f"
|
||||
@@ -241,6 +241,24 @@ services:
|
||||
done
|
||||
echo "[grampsweb] Done."
|
||||
fi
|
||||
echo "[grampsweb] Ensuring admin user exists ..."
|
||||
python3 << 'PYEOF' 2>&1 | grep -v Gtk
|
||||
from gramps_webapi.app import create_app
|
||||
from gramps_webapi.auth import add_user, get_number_users, ROLE_OWNER
|
||||
import os
|
||||
email = os.environ.get('GRAMPSWEB_ADMIN_EMAIL', '')
|
||||
pw = os.environ.get('GRAMPSWEB_ADMIN_PASSWORD', '')
|
||||
if email and pw:
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
if get_number_users() == 0:
|
||||
add_user(name='Admin', email=email, password=pw, role=ROLE_OWNER)
|
||||
print('[grampsweb] Admin user created')
|
||||
else:
|
||||
print('[grampsweb] Users already exist, skipping')
|
||||
else:
|
||||
print('[grampsweb] No admin credentials configured, skipping')
|
||||
PYEOF
|
||||
exec gunicorn -w $${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 \
|
||||
gramps_webapi.wsgi:app --timeout $${GUNICORN_TIMEOUT:-120} \
|
||||
--limit-request-line 8190
|
||||
|
||||
@@ -158,8 +158,8 @@ services:
|
||||
echo "[grampsweb] patched JS paths: $$f"
|
||||
fi
|
||||
done
|
||||
for f in /app/static/*.css; do
|
||||
if [ -f "$$f" ] && grep -q 'fonts/' "$$f" 2>/dev/null; then
|
||||
find /app/static -name '*.css' 2>/dev/null | while read f; do
|
||||
if grep -q '\.\./fonts/' "$$f" 2>/dev/null; then
|
||||
sed -i "s|'../fonts/|'fonts/|g" "$$f"
|
||||
sed -i "s|\"../fonts/|\"fonts/|g" "$$f"
|
||||
echo "[grampsweb] patched CSS font paths: $$f"
|
||||
@@ -167,6 +167,24 @@ services:
|
||||
done
|
||||
echo "[grampsweb] Done."
|
||||
fi
|
||||
echo "[grampsweb] Ensuring admin user exists ..."
|
||||
python3 << 'PYEOF' 2>&1 | grep -v Gtk
|
||||
from gramps_webapi.app import create_app
|
||||
from gramps_webapi.auth import add_user, get_number_users, ROLE_OWNER
|
||||
import os
|
||||
email = os.environ.get('GRAMPSWEB_ADMIN_EMAIL', '')
|
||||
pw = os.environ.get('GRAMPSWEB_ADMIN_PASSWORD', '')
|
||||
if email and pw:
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
if get_number_users() == 0:
|
||||
add_user(name='Admin', email=email, password=pw, role=ROLE_OWNER)
|
||||
print('[grampsweb] Admin user created')
|
||||
else:
|
||||
print('[grampsweb] Users already exist, skipping')
|
||||
else:
|
||||
print('[grampsweb] No admin credentials configured, skipping')
|
||||
PYEOF
|
||||
exec gunicorn -w $${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 \
|
||||
gramps_webapi.wsgi:app --timeout $${GUNICORN_TIMEOUT:-120} \
|
||||
--limit-request-line 8190
|
||||
|
||||
Reference in New Issue
Block a user