Files
MeDBia/videodb/docker-entrypoint.sh
Malin 6002fc6e58 feat: add macOS disc scanner + API ingest endpoint
- scanner/scan_disc.py: polls optical drive via drutil, detects disc type
  (DVD/Blu-ray/Audio CD/Data CD), reads volume label, file/track count,
  posts to remote API, auto-ejects. Pure Python + requests, no drivers.
- scanner/requirements.txt + README.md: setup and usage docs
- videodb/api_ingest.php: authenticated POST endpoint that writes disc
  records directly into the videoDB MySQL schema; token stored in config
- docker-compose.yml: adds INGEST_API_TOKEN env var
- docker-entrypoint.sh: writes ingest_api_token into config.inc.php

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 09:58:11 +02:00

89 lines
3.3 KiB
Bash

#!/bin/bash
set -e
DB_HOST="${DB_HOST:-db}"
DB_USER="${DB_USER:-videodb}"
DB_PASSWORD="${DB_PASSWORD:-videodb_secret}"
DB_NAME="${DB_NAME:-videodb}"
DB_PREFIX="${DB_PREFIX:-videodb_}"
INGEST_API_TOKEN="${INGEST_API_TOKEN:-changeme}"
CONFIG_FILE="/var/www/html/config.inc.php"
# ── Write config.inc.php from environment variables ──────────────────────────
cat > "$CONFIG_FILE" <<PHP
<?php
\$config['db_server'] = '${DB_HOST}';
\$config['db_user'] = '${DB_USER}';
\$config['db_password'] = '${DB_PASSWORD}';
\$config['db_database'] = '${DB_NAME}';
\$config['db_prefix'] = '${DB_PREFIX}';
\$config['offline'] = 0;
\$config['debug'] = 0;
\$config['httpclientlog'] = 0;
\$config['IMDBage'] = 604800;
\$config['hierarchical'] = 1;
\$config['cache_pruning'] = 1;
\$config['http_caching'] = 0;
\$config['lookupdefault_edit'] = 0;
\$config['lookupdefault_new'] = 2;
\$config['diskid_digits'] = 4;
\$config['thumbnail_level'] = 1;
\$config['thumbnail_quality'] = 80;
\$config['xml'] = 0;
\$config['xml_thumbnails'] = 0;
\$config['rss'] = 1;
\$config['pdf'] = 1;
\$config['pdf_font_title'] = 'Arial';
\$config['pdf_font_plot'] = 'Times';
\$config['pdf_font_size'] = 10;
\$config['pdf_image_max_width'] = 95;
\$config['pdf_image_max_height'] = 135;
\$config['pdf_image_media_width'] = 8;
\$config['pdf_page_width'] = 210;
\$config['pdf_text_length'] = 500;
\$config['pdf_margin'] = 5;
\$config['pdf_left_margin'] = 5;
\$config['pdf_right_margin'] = 5;
\$config['pdf_image_height'] = 24;
\$config['pdf_image_width'] = intval((\$config['pdf_image_max_width'] / \$config['pdf_image_max_height']) * \$config['pdf_image_height']);
\$config['xls'] = 1;
\$config['xls_sheet_title'] = 'VideoDB';
\$config['xls_output_filename'] = 'VideoDB';
\$config['xls_show_headline'] = 1;
\$config['xls_mark_unseen'] = 1;
\$config['xls_mark_lent'] = 1;
\$config['xls_extra_fields'] = 'title (plot), diskid, genres, language, mediatype, runtime, year, custom1, custom2, custom3, custom4, insertdate, owner, lent';
\$config['dvdb_user'] = '';
\$config['dvdb_password'] = '';
\$config['ingest_api_token'] = '${INGEST_API_TOKEN}';
PHP
chown www-data:www-data "$CONFIG_FILE"
echo "[entrypoint] config.inc.php written."
# ── Wait for MySQL ─────────────────────────────────────────────────────────────
echo "[entrypoint] Waiting for MySQL at ${DB_HOST}..."
until mysqladmin ping -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASSWORD" --silent 2>/dev/null; do
printf "."
sleep 2
done
echo ""
echo "[entrypoint] MySQL is ready."
# ── Initialize DB schema (idempotent) ─────────────────────────────────────────
php /usr/local/bin/init-db.php
# ── Ensure cache dirs exist and are writable ──────────────────────────────────
mkdir -p \
/var/www/html/cache/smarty \
/var/www/html/cache/imdb \
/var/www/html/cache/img \
/var/www/html/cache/thumbs \
/var/www/html/cache/javascript \
/var/www/html/cache/local
chown -R www-data:www-data /var/www/html/cache /var/www/html/images
echo "[entrypoint] Starting Apache..."
exec "$@"