first install

This commit is contained in:
lelo 2025-03-16 21:04:43 +00:00
parent a8813e57da
commit 5dd26db2be
12 changed files with 71 additions and 33 deletions

BIN
.filecache/cache.db Normal file

Binary file not shown.

BIN
.filecache/cache.db-shm Normal file

Binary file not shown.

0
.filecache/cache.db-wal Normal file
View File

1
.gitignore vendored
View File

@ -1 +1,2 @@
/venv
/filecache

Binary file not shown.

4
app.py Normal file → Executable file
View File

@ -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),

0
apply_correction.py Normal file → Executable file
View File

71
check_ssh_tunnel.sh Normal file → Executable file
View File

@ -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/tcp/localhost/${LOCAL_PORT}" &>/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 "SSH Tunnel is active."
echo "[ERROR] Failed to establish SSH tunnel!"
exit 1
fi
else
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

21
docker-compose.yml Normal file → Executable file
View File

@ -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"

0
error_correction.json Normal file → Executable file
View File

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
flask
pillow
diskcache

0
transcribe_all.py Normal file → Executable file
View File