diff --git a/.filecache/cache.db b/.filecache/cache.db new file mode 100644 index 0000000..f887a38 Binary files /dev/null and b/.filecache/cache.db differ diff --git a/.filecache/cache.db-shm b/.filecache/cache.db-shm new file mode 100644 index 0000000..fe9ac28 Binary files /dev/null and b/.filecache/cache.db-shm differ diff --git a/.filecache/cache.db-wal b/.filecache/cache.db-wal new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore index a979ee7..38c0bf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/venv \ No newline at end of file +/venv +/filecache diff --git a/__pycache__/app.cpython-311.pyc b/__pycache__/app.cpython-311.pyc new file mode 100644 index 0000000..dde611f Binary files /dev/null and b/__pycache__/app.cpython-311.pyc differ diff --git a/app.py b/app.py old mode 100644 new mode 100755 index 5b541bc..683c7a5 --- a/app.py +++ b/app.py @@ -7,12 +7,12 @@ import mimetypes from datetime import datetime from urllib.parse import unquote import diskcache -cache = diskcache.Cache('./filecache', size_limit= 124**3) # 124MB limit +cache = diskcache.Cache('./filecache', size_limit= 32 * 1024**3) # 32 GB limit app = Flask(__name__) # Use a raw string for the UNC path. -app.config['MP3_ROOT'] = r'\\192.168.10.10\docker2\sync-bethaus\syncfiles\folders' +app.config['MP3_ROOT'] = r'/mp3_root' app.config['SECRET_KEY'] = os.urandom(24) app.config['ALLOWED_SECRETS'] = { 'test': datetime(2026, 3, 31, 23, 59, 59), diff --git a/apply_correction.py b/apply_correction.py old mode 100644 new mode 100755 diff --git a/check_ssh_tunnel.sh b/check_ssh_tunnel.sh old mode 100644 new mode 100755 index bf2cc7c..9176225 --- a/check_ssh_tunnel.sh +++ b/check_ssh_tunnel.sh @@ -1,19 +1,62 @@ -# SSH Tunnel Check Script (batch script for cron) -# Add to cron: */5 * * * * /path/to/check_ssh_tunnel.sh - -# --- Script to ensure SSH Tunnel is active --- - #!/bin/bash -SSH_USER="your_ssh_user" -SSH_SERVER="ssh-server-address" -LOCAL_PORT="2049" -REMOTE_NFS_SERVER="nfs-server-address" +# SSH and NFS Tunnel Configuration +SSH_USER="root" +SSH_SERVER="bethaus-speyer.de" +SSH_SERVER_PORT=1122 # Remote SSH server SSH port +LOCAL_PORT=2022 # Local port for NFS tunnel +REMOTE_NFS_PORT=2049 # Remote NFS server port +MOUNT_POINT="/mnt/app.bethaus/Gottesdienste Speyer" +NFS_SHARE="/volume1/Aufnahme-stereo/010 Gottesdienste ARCHIV" -# Check if tunnel is active -if ! nc -z localhost $LOCAL_PORT; then - echo "SSH Tunnel is down! Reconnecting..." - ssh -f -N -L ${LOCAL_PORT}:$SSH_SERVER:2049 ${SSH_USER}@${SSH_SERVER} +# Function to check if the SSH tunnel is active +is_tunnel_active() { + timeout 1 bash -c "/dev/null +} + +# Function to check if the NFS share is mounted +is_nfs_mounted() { + mount | grep -q "${MOUNT_POINT}" +} + +# Restart the SSH tunnel if it's not running +if ! is_tunnel_active; then + echo "[INFO] SSH Tunnel is down. Attempting to reconnect..." + + ssh -f -N -L "${LOCAL_PORT}:localhost:${REMOTE_NFS_PORT}" \ + -o ExitOnForwardFailure=yes \ + -p "${SSH_SERVER_PORT}" \ + "${SSH_USER}@${SSH_SERVER}" + + if is_tunnel_active; then + echo "[SUCCESS] SSH Tunnel established on local port ${LOCAL_PORT}, forwarding to remote NFS port ${REMOTE_NFS_PORT}." + else + echo "[ERROR] Failed to establish SSH tunnel!" + exit 1 + fi else - echo "SSH Tunnel is active." -fi \ No newline at end of file + echo "[INFO] SSH Tunnel is already active on port ${LOCAL_PORT}." +fi + +# Ensure mount point exists +if [ ! -d "${MOUNT_POINT}" ]; then + echo "[INFO] Creating mount point: ${MOUNT_POINT}" + sudo mkdir -p "${MOUNT_POINT}" +fi + +# Mount the NFS share if it's not already mounted +if ! is_nfs_mounted; then + echo "[INFO] NFS is not mounted. Attempting to mount..." + + sudo mount -t nfs -o port=${LOCAL_PORT},nolock,soft 127.0.0.1:"${NFS_SHARE}" "${MOUNT_POINT}" + + if is_nfs_mounted; then + echo "[SUCCESS] NFS mounted successfully at ${MOUNT_POINT}." + else + echo "[ERROR] Failed to mount NFS share!" + exit 1 + fi +else + echo "[INFO] NFS is already mounted at ${MOUNT_POINT}." +fi + diff --git a/docker-compose.yml b/docker-compose.yml old mode 100644 new mode 100755 index a082b75..76f4b3b --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,29 +1,20 @@ services: flask-app: image: python:3.11-slim - container_name: flask-app + container_name: bethaus-app restart: always working_dir: /app volumes: - ./:/app - - filecache:/app/filecache - - templates:/app/templates - - mp3_root:/mp3_root + - ./filecache:/app/filecache + - ./templates:/app/templates + - /mnt/app.bethaus:/mp3_root:ro environment: - FLASK_APP=app.py - FLASK_RUN_HOST=0.0.0.0 + - FLASK_ENV=production - MP3_ROOT=/mp3_root ports: - "5000:5000" command: > - sh -c "pip install flask pillow diskcache && flask run" - -volumes: - filecache: - templates: - mp3_root: - driver: local - driver_opts: - type: nfs - o: addr=127.0.0.1,rw,nolock,soft - device: ":/path/to/your/nfs/export" + sh -c "pip install -r requirements.txt && flask run" diff --git a/error_correction.json b/error_correction.json old mode 100644 new mode 100755 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..62ac035 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +flask +pillow +diskcache diff --git a/transcribe_all.py b/transcribe_all.py old mode 100644 new mode 100755